mirror of
https://gitea.bearcatlog.com/Bryant/chassis
synced 2025-01-19 02:24:43 +08:00
fix bug 6
This commit is contained in:
parent
b7a6115ce9
commit
b1773a4b81
@ -16,9 +16,11 @@ class Config:
|
||||
# 指定数据库
|
||||
DEFAULT_DATABASE_URI = os.getenv('DEFAULT_DATABASE_URI')
|
||||
READONLY_DATABASE_URI = os.getenv('READONLY_DATABASE_URI')
|
||||
const.DB_CONFIG_ITEM = {
|
||||
const.DEFAULT_DB_KEY: DEFAULT_DATABASE_URI,
|
||||
const.READONLY_DB_KEY: READONLY_DATABASE_URI,
|
||||
DB_CONFIG_ITEM = {
|
||||
const.DB_CONFIG_ITEM: {
|
||||
const.DEFAULT_DB_KEY: DEFAULT_DATABASE_URI,
|
||||
const.READONLY_DB_KEY: READONLY_DATABASE_URI,
|
||||
}
|
||||
}
|
||||
|
||||
STATSD_PREFIX = os.getenv('STATSD_PREFIX')
|
||||
|
@ -7,11 +7,11 @@ from chassis.consts import const
|
||||
engines = {}
|
||||
|
||||
|
||||
def init_engine(config):
|
||||
if config:
|
||||
databases = getattr(config, const.DB_CONFIG_ITEM)
|
||||
def init_engine(config_item):
|
||||
if config_item:
|
||||
databases = config_item[const.DB_CONFIG_ITEM]
|
||||
else:
|
||||
databases = getattr(Config, const.DB_CONFIG_ITEM)
|
||||
databases = Config.DB_CONFIG_ITEM[const.DB_CONFIG_ITEM]
|
||||
for db_key, db_url in databases.items():
|
||||
engine = create_engine(db_url,
|
||||
logging_name=db_key, poolclass=None, pool_size=5, max_overflow=20, pool_recycle=3600,
|
||||
|
Loading…
Reference in New Issue
Block a user