Project

General

Profile

« Previous | Next » 

Revision 2729

sql.py: tables(): Added exact param to check for exact matches only

View differences:

lib/sql.py
1002 1002
    db.with_autocommit(lambda: run_query(db, 'VACUUM ANALYZE '+table.to_str(db),
1003 1003
        log_level=3))
1004 1004

  
1005
def tables(db, schema_like='public', table_like='%'):
1005
def tables(db, schema_like='public', table_like='%', exact=False):
1006
    if exact: compare = '='
1007
    else: compare = 'LIKE'
1008
    
1006 1009
    module = util.root_module(db.db)
1007 1010
    params = {'schema_like': schema_like, 'table_like': table_like}
1008 1011
    if module == 'psycopg2':
......
1010 1013
SELECT tablename
1011 1014
FROM pg_tables
1012 1015
WHERE
1013
    schemaname LIKE %(schema_like)s
1014
    AND tablename LIKE %(table_like)s
1016
    schemaname '''+compare+''' %(schema_like)s
1017
    AND tablename '''+compare+''' %(table_like)s
1015 1018
ORDER BY tablename
1016 1019
''',
1017 1020
            params, cacheable=True))

Also available in: Unified diff