summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/sqlite/base.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-07-13 19:07:35 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-07-13 19:07:35 +0000
commit5cae798ba9ead35dabf91da24b216a56415333c3 (patch)
treee1ac7ad3e4ff1a9193bb1d31151280769a145f91 /lib/sqlalchemy/dialects/sqlite/base.py
parent99d3f173dcb0eea88871102e89cf05ce3be9b4cb (diff)
parent9d0fb152069caa8de887aba28cef87f7acb32e37 (diff)
downloadsqlalchemy-2020_tutorial.tar.gz
Merge "test single and double quote inspection scenarios"2020_tutorial
Diffstat (limited to 'lib/sqlalchemy/dialects/sqlite/base.py')
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index 0475a397e..3a8ffa23d 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -1668,27 +1668,26 @@ class SQLiteDialect(default.DefaultDialect):
if schema is not None:
qschema = self.identifier_preparer.quote_identifier(schema)
master = "%s.sqlite_master" % qschema
- s = ("SELECT sql FROM %s WHERE name = '%s'" "AND type='view'") % (
+ s = ("SELECT sql FROM %s WHERE name = ? AND type='view'") % (
master,
- view_name,
)
- rs = connection.exec_driver_sql(s)
+ rs = connection.exec_driver_sql(s, (view_name,))
else:
try:
s = (
"SELECT sql FROM "
" (SELECT * FROM sqlite_master UNION ALL "
" SELECT * FROM sqlite_temp_master) "
- "WHERE name = '%s' "
+ "WHERE name = ? "
"AND type='view'"
- ) % view_name
- rs = connection.exec_driver_sql(s)
+ )
+ rs = connection.exec_driver_sql(s, (view_name,))
except exc.DBAPIError:
s = (
- "SELECT sql FROM sqlite_master WHERE name = '%s' "
+ "SELECT sql FROM sqlite_master WHERE name = ? "
"AND type='view'"
- ) % view_name
- rs = connection.exec_driver_sql(s)
+ )
+ rs = connection.exec_driver_sql(s, (view_name,))
result = rs.fetchall()
if result:
@@ -2136,19 +2135,17 @@ class SQLiteDialect(default.DefaultDialect):
"SELECT sql FROM "
" (SELECT * FROM %(schema)ssqlite_master UNION ALL "
" SELECT * FROM %(schema)ssqlite_temp_master) "
- "WHERE name = '%(table)s' "
- "AND type = 'table'"
- % {"schema": schema_expr, "table": table_name}
+ "WHERE name = ? "
+ "AND type = 'table'" % {"schema": schema_expr}
)
- rs = connection.exec_driver_sql(s)
+ rs = connection.exec_driver_sql(s, (table_name,))
except exc.DBAPIError:
s = (
"SELECT sql FROM %(schema)ssqlite_master "
- "WHERE name = '%(table)s' "
- "AND type = 'table'"
- % {"schema": schema_expr, "table": table_name}
+ "WHERE name = ? "
+ "AND type = 'table'" % {"schema": schema_expr}
)
- rs = connection.exec_driver_sql(s)
+ rs = connection.exec_driver_sql(s, (table_name,))
return rs.scalar()
def _get_table_pragma(self, connection, pragma, table_name, schema=None):