"""Produce an engine configured by --options with optional overrides."""
from sqlalchemy import create_engine
+ from sqlalchemy.engine.url import make_url
if not options:
use_reaper = True
use_reaper = options.pop('use_reaper', True)
url = url or config.db.url
+
+ url = make_url(url)
if options is None:
- options = config.db_opts
+ if config.db is None or url.drivername == config.db.url.drivername:
+ options = config.db_opts
+ else:
+ options = {}
engine = create_engine(url, **options)
- engine._has_events = True # enable event blocks, helps with
- # profiling
+ engine._has_events = True # enable event blocks, helps with profiling
if isinstance(engine.pool, pool.QueuePool):
engine.pool._timeout = 0