server/sqlutils.py
branchstable
changeset 2396 8bfb99d7bbcc
parent 1977 606923dff11b
child 2493 9806571ea790
equal deleted inserted replaced
2395:e3093fc12a00 2396:8bfb99d7bbcc
    27 
    27 
    28 lgc.USE_MX_DATETIME = False
    28 lgc.USE_MX_DATETIME = False
    29 SQL_PREFIX = 'cw_'
    29 SQL_PREFIX = 'cw_'
    30 
    30 
    31 
    31 
    32 def sqlexec(sqlstmts, cursor_or_execute, withpb=True, delimiter=';'):
    32 def sqlexec(sqlstmts, cursor_or_execute, withpb=True, pbtitle='', delimiter=';'):
    33     """execute sql statements ignoring DROP/ CREATE GROUP or USER statements
    33     """execute sql statements ignoring DROP/ CREATE GROUP or USER statements
    34     error. If a cnx is given, commit at each statement
    34     error. If a cnx is given, commit at each statement
    35     """
    35     """
    36     if hasattr(cursor_or_execute, 'execute'):
    36     if hasattr(cursor_or_execute, 'execute'):
    37         execute = cursor_or_execute.execute
    37         execute = cursor_or_execute.execute
    38     else:
    38     else:
    39         execute = cursor_or_execute
    39         execute = cursor_or_execute
    40     sqlstmts = sqlstmts.split(delimiter)
    40     sqlstmts = sqlstmts.split(delimiter)
    41     if withpb:
    41     if withpb:
    42         pb = ProgressBar(len(sqlstmts))
    42         pb = ProgressBar(len(sqlstmts), title=pbtitle)
    43     for sql in sqlstmts:
    43     for sql in sqlstmts:
    44         sql = sql.strip()
    44         sql = sql.strip()
    45         if withpb:
    45         if withpb:
    46             pb.update()
    46             pb.update()
    47         if not sql:
    47         if not sql: