Revision 2779
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1037 | 1037 |
module = util.root_module(db.db) |
1038 | 1038 |
params = {'schema_like': schema_like, 'table_like': table_like} |
1039 | 1039 |
if module == 'psycopg2': |
1040 |
return values(run_query(db, '''\ |
|
1041 |
SELECT tablename |
|
1042 |
FROM pg_tables |
|
1043 |
WHERE |
|
1044 |
schemaname '''+compare+''' %(schema_like)s |
|
1045 |
AND tablename '''+compare+''' %(table_like)s |
|
1046 |
ORDER BY tablename |
|
1047 |
''', |
|
1048 |
params, cacheable=True, log_level=4)) |
|
1040 |
conds = [('schemaname', sql_gen.CompareCond(schema_like, compare)), |
|
1041 |
('tablename', sql_gen.CompareCond(table_like, compare))] |
|
1042 |
return values(select(db, 'pg_tables', ['tablename'], conds, |
|
1043 |
order_by='tablename', log_level=4)) |
|
1049 | 1044 |
elif module == 'MySQLdb': |
1050 |
return values(run_query(db, 'SHOW TABLES LIKE %(table_like)s', params,
|
|
1051 |
cacheable=True, log_level=4)) |
|
1045 |
return values(run_query(db, 'SHOW TABLES LIKE '+db.esc_value(table_like)
|
|
1046 |
, cacheable=True, log_level=4))
|
|
1052 | 1047 |
else: raise NotImplementedError("Can't list tables for "+module+' database') |
1053 | 1048 |
|
1054 | 1049 |
def table_exists(db, table): |
Also available in: Unified diff
sql.py: tables(): Use select() instead of a custom run_query() to avoid using params, which will be deprecated to make it easier to support old versions of Python