Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(3)  |  Call(3)  |  Derive(0)  |  Import(0)
execute an sql ``statement``.

If ``error`` is given, it is scanned for locking issues.

Retry ``retries`` times if set to a positive number.
A retry of ``0`` indicates no retry, a negative number retries
infinitely. 

The process waits ``wait`` seconds between each retry.
(more...)

        def executewait( dbhandle, statement, error = None, retries = -1, wait=5):
    '''execute an sql ``statement``.

    If ``error`` is given, it is scanned for locking issues.

    Retry ``retries`` times if set to a positive number.
    A retry of ``0`` indicates no retry, a negative number retries
    infinitely. 

    The process waits ``wait`` seconds between each retry.

    Returns a cursor object.
    '''
    if error == None: error = Exception

    cc = dbhandle.cursor()    

    while 1:
        try:
            cc.execute( statement )
        except error, msg:
            if retries == 0:
                raise error, msg
            if not re.search("locked", str(msg)):
                raise error, msg
            time.sleep(wait)
            retries -= 1
            continue
        break
    return cc
        


src/c/g/CGAT-0.2.0/CGAT/Pipeline.py   CGAT(Download)
    '''
 
    Database.executewait( dbhandle, "DROP %(view_type)s IF EXISTS %(tablename)s" % locals() )
 
    tracks, columns = [], []
    tablenames = [ x[0] for x in tables ]
    for table, track in tables:
        d = Database.executewait( dbhandle,"SELECT COUNT(DISTINCT %s) FROM %s" % (track,table))
    ''' % locals()
 
    Database.executewait( dbhandle, statement )
 
    nrows = Database.executewait( dbhandle, "SELECT COUNT(*) FROM view_mapping" ).fetchone()[0]