From adb495503dab660f014cad0200491c854d2f6a50 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 20 Sep 2019 09:25:40 -0400 Subject: Support SQLite URIs Added support for sqlite "URI" connections, which allow for sqlite-specific flags to be passed in the query string such as "read only" for Python sqlite3 drivers that support this. Fixes: #4863 Change-Id: I7740b55ee8f2ede72a5c49ee94a7540e4d0250f2 --- lib/sqlalchemy/util/langhelpers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/util') diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index f3f3f9ea5..83f119660 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1126,21 +1126,24 @@ def asint(value): return int(value) -def coerce_kw_type(kw, key, type_, flexi_bool=True): +def coerce_kw_type(kw, key, type_, flexi_bool=True, dest=None): r"""If 'key' is present in dict 'kw', coerce its value to type 'type\_' if necessary. If 'flexi_bool' is True, the string '0' is considered false when coercing to boolean. """ + if dest is None: + dest = kw + if ( key in kw and (not isinstance(type_, type) or not isinstance(kw[key], type_)) and kw[key] is not None ): if type_ is bool and flexi_bool: - kw[key] = asbool(kw[key]) + dest[key] = asbool(kw[key]) else: - kw[key] = type_(kw[key]) + dest[key] = type_(kw[key]) def constructor_key(obj, cls): -- cgit v1.2.1