|
@@ -0,0 +1,12 @@
|
|
|
+from urllib.parse import quote_plus
|
|
|
+
|
|
|
+from sqlalchemy import create_engine
|
|
|
+
|
|
|
+def create_sql_engine(config):
|
|
|
+ user = config['user']
|
|
|
+ passwd = quote_plus(config['password'])
|
|
|
+ host = config['host']
|
|
|
+ db_name = config['database']
|
|
|
+ charset = config.get('charset', 'utf8mb4')
|
|
|
+ engine = create_engine(f'mysql+pymysql://{user}:{passwd}@{host}/{db_name}?charset={charset}')
|
|
|
+ return engine
|