url = url or config.db.url
url = make_url(url)
- if options is None:
- if config.db is None or url.drivername == config.db.url.drivername:
- options = config.db_opts
- else:
- options = {}
- elif config.db is not None and url.drivername == config.db.url.drivername:
- default_opt = config.db_opts.copy()
- default_opt.update(options)
- engine = create_engine(url, **options)
+ if (
+ config.db is None or url.drivername == config.db.url.drivername
+ ) and config.db_opts:
+ use_options = config.db_opts.copy()
+ else:
+ use_options = {}
+
+ if options is not None:
+ use_options.update(options)
+
+ engine = create_engine(url, **use_options)
if sqlite_savepoint and engine.name == "sqlite":
# apply SQLite savepoint workaround
if (
isinstance(engine.pool, pool.QueuePool)
- and "pool" not in options
- and "pool_timeout" not in options
- and "max_overflow" not in options
+ and "pool" not in use_options
+ and "pool_timeout" not in use_options
+ and "max_overflow" not in use_options
):
engine.pool._timeout = 0
engine.pool._max_overflow = 0