Project

General

Profile

« Previous | Next » 

Revision 2913

sql.py: Added function_exists()

View differences:

sql.py
1058 1058
    table = sql_gen.as_Table(table)
1059 1059
    return list(tables(db, table.schema, table.name, exact=True)) != []
1060 1060

  
1061
def function_exists(db, function):
1062
    function = sql_gen.as_Function(function)
1063
    
1064
    info_table = sql_gen.Table('routines', 'information_schema')
1065
    conds = [('routine_name', function.name)]
1066
    schema = function.schema
1067
    if schema != None: conds.append(('routine_schema', schema))
1068
    
1069
    return list(values(select(db, info_table, ['routine_name'], conds,
1070
        order_by='routine_schema', limit=1, log_level=4))) != []
1071
        # TODO: order_by search_path schema order
1072

  
1061 1073
def errors_table(db, table, if_exists=True):
1062 1074
    '''
1063 1075
    @param if_exists If set, returns None if the errors table doesn't exist

Also available in: Unified diff