Changes between Initial Version and Version 1 of Ticket #13321, comment 4
- Timestamp:
- Mar 28, 2019, 1:56:00 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #13321, comment 4
initial v1 6 6 {{{#!diff 7 7 diff --git a/timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/dbhelper.py b/timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/dbhelper.py 8 index 362ce21ab.. fab89e6141006448 index 362ce21ab..7422d27a6 100644 9 9 --- a/timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/dbhelper.py 10 10 +++ b/timingandestimationplugin/branches/trac1.0-Permissions/timingandestimationplugin/dbhelper.py … … 23 23 try: 24 24 cur = db.cursor() 25 @@ -118,17 +119,2 3@@ def _prep_schema(s):25 @@ -118,17 +119,22 @@ def _prep_schema(s): 26 26 for i in s.split(','))) 27 27 28 28 def db_table_exists(env, table): 29 29 - cnt = 0 30 - with env.db_query as db: 31 - if is_db_type(db, SqliteCon): 32 - sql = "select count(*) from sqlite_master where type = 'table' and name = %s" 33 - cnt = get_scalar(env, sql, 0, table) 34 - else: 35 - sql = """SELECT count(*) FROM information_schema.tables 36 - WHERE table_name = %%s and table_schema in (%s) 37 - """ % _prep_schema(current_schema(env)) 38 - cnt = get_scalar(env, sql, 0, table) 39 - return cnt 30 40 + connection_uri = DatabaseManager(env).connection_uri 31 41 + if connection_uri.startswith('sqlite:'): … … 42 52 + else: 43 53 + raise NotImplementedError() 44 with env.db_query as db: 45 - if is_db_type(db, SqliteCon): 46 - sql = "select count(*) from sqlite_master where type = 'table' and name = %s" 47 - cnt = get_scalar(env, sql, 0, table) 48 - else: 49 - sql = """SELECT count(*) FROM information_schema.tables 50 - WHERE table_name = %%s and table_schema in (%s) 51 - """ % _prep_schema(current_schema(env)) 52 - cnt = get_scalar(env, sql, 0, table) 53 - return cnt 54 + rows = db(sql, [table]) 55 + return rows[0][0] 54 + rows = env.db_query(sql, [table]) 55 + return rows[0][0] 56 56 57 57 def get_column_as_list(env, sql, col=0, *params):