Add debug sqlalchemy logs (disabled by default)
This commit is contained in:
parent
cd67b0934e
commit
55a369df83
|
@ -26,7 +26,7 @@ else:
|
||||||
|
|
||||||
def _no_database():
|
def _no_database():
|
||||||
print('Database unavailable or not configured properly')
|
print('Database unavailable or not configured properly')
|
||||||
exit(lacre.EX_CONFIG)
|
sys.exit(lacre.EX_CONFIG)
|
||||||
|
|
||||||
|
|
||||||
def sub_queue(args):
|
def sub_queue(args):
|
||||||
|
|
|
@ -17,17 +17,17 @@ _HOUR_IN_SECONDS = 3600
|
||||||
_engine = None
|
_engine = None
|
||||||
|
|
||||||
|
|
||||||
def init_engine(url):
|
def init_engine(url, db_debug=False):
|
||||||
global _engine
|
global _engine
|
||||||
|
|
||||||
if not _engine:
|
if not _engine:
|
||||||
config = _conn_config()
|
config = _conn_config(db_debug)
|
||||||
_engine = create_engine(url, **config)
|
_engine = create_engine(url, **config)
|
||||||
|
|
||||||
return _engine
|
return _engine
|
||||||
|
|
||||||
|
|
||||||
def _conn_config():
|
def _conn_config(db_debug):
|
||||||
config = dict()
|
config = dict()
|
||||||
|
|
||||||
mode = PoolingMode.from_config('database', 'pooling_mode', required=True)
|
mode = PoolingMode.from_config('database', 'pooling_mode', required=True)
|
||||||
|
@ -45,6 +45,10 @@ def _conn_config():
|
||||||
if config_item_set('database', 'max_overflow'):
|
if config_item_set('database', 'max_overflow'):
|
||||||
config['max_overflow'] = int(get_item('database', 'max_overflow'))
|
config['max_overflow'] = int(get_item('database', 'max_overflow'))
|
||||||
|
|
||||||
|
if db_debug:
|
||||||
|
config['echo'] = 'debug'
|
||||||
|
config['echo_pool'] = 'debug'
|
||||||
|
|
||||||
LOG.debug('Database engine configuration: %s', config)
|
LOG.debug('Database engine configuration: %s', config)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue