Revision 4555
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/sql.py | ||
---|---|---|
1051 | 1051 |
|
1052 | 1052 |
#### Tables |
1053 | 1053 |
|
1054 |
def tables(db, schema_like='public', table_like='%', exact=False): |
|
1054 |
def tables(db, schema_like='public', table_like='%', exact=False, |
|
1055 |
cacheable=True): |
|
1055 | 1056 |
if exact: compare = '=' |
1056 | 1057 |
else: compare = 'LIKE' |
1057 | 1058 |
|
... | ... | |
1060 | 1061 |
conds = [('schemaname', sql_gen.CompareCond(schema_like, compare)), |
1061 | 1062 |
('tablename', sql_gen.CompareCond(table_like, compare))] |
1062 | 1063 |
return values(select(db, 'pg_tables', ['tablename'], conds, |
1063 |
order_by='tablename', log_level=4)) |
|
1064 |
order_by='tablename', cacheable=cacheable, log_level=4))
|
|
1064 | 1065 |
elif module == 'MySQLdb': |
1065 | 1066 |
return values(run_query(db, 'SHOW TABLES LIKE '+db.esc_value(table_like) |
1066 | 1067 |
, cacheable=True, log_level=4)) |
Also available in: Unified diff
sql.py: tables(): Allow caller to set whether query will be cached