Project

General

Profile

« Previous | Next » 

Revision 7242

sql.py: Added view_exists()

View differences:

lib/sql.py
1264 1264
        except DoesNotExistException: pass
1265 1265
    return table.order_by
1266 1266

  
1267
#### Views
1268

  
1269
def view_exists(db, view):
1270
    view_str = sql_gen.Literal(view.to_str(db))
1271
    try:
1272
        return value(run_query(db, '''\
1273
SELECT relkind = 'v'
1274
FROM pg_class
1275
WHERE oid = '''+view_str.to_str(db)+'''::regclass
1276
'''
1277
            , cacheable=True, log_level=4))
1278
    except DoesNotExistException: return False
1279

  
1267 1280
#### Functions
1268 1281

  
1269 1282
def function_exists(db, function):

Also available in: Unified diff