新增一键运行功能
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
|
||||
|
||||
TUSHARE_TOKEN = os.getenv(
|
||||
"TUSHARE_TOKEN",
|
||||
"0fad3cf498757089e2630028455d5bbe1637475788bcdaa1f2175e93",
|
||||
)
|
||||
|
||||
DB_CONFIG = {
|
||||
"host": os.getenv("MYSQL_HOST", "8.159.129.156"),
|
||||
"port": int(os.getenv("MYSQL_PORT", "10836")),
|
||||
"user": os.getenv("MYSQL_USER", "yangfan"),
|
||||
"password": os.getenv("MYSQL_PASSWORD", "aA%8023321088"),
|
||||
"database": os.getenv("MYSQL_DATABASE", "level"),
|
||||
"charset": os.getenv("MYSQL_CHARSET", "utf8mb4"),
|
||||
}
|
||||
|
||||
|
||||
def get_db_url():
|
||||
return (
|
||||
f"mysql+pymysql://{DB_CONFIG['user']}@{DB_CONFIG['host']}:"
|
||||
f"{DB_CONFIG['port']}/{DB_CONFIG['database']}?charset={DB_CONFIG['charset']}"
|
||||
)
|
||||
|
||||
|
||||
def get_engine():
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
return create_engine(
|
||||
get_db_url(),
|
||||
connect_args={"password": DB_CONFIG["password"]},
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
Reference in New Issue
Block a user