tests/delayedquery.py
author Radek Brich <radek.brich@devl.cz>
Tue, 11 Dec 2012 11:25:06 +0100
changeset 53 4a049a5af657
parent 22 680631f35d83
child 78 64c62ac8f65d
permissions -rwxr-xr-x
Update PgDiff: Support SQL patch for constraints. Fix changes of column default value.

#!/usr/bin/env python3

import logging
import time

from config import Config
from pgtoolkit import pgmanager
from pgtoolkit.delayedquery import DelayedQuery


if __name__ == '__main__':
    cfg = Config('tests.conf')
    
    pgm = pgmanager.get_instance()
    pgm.create_conn(isolation_level = 'autocommit', **cfg)
    
    handler = logging.StreamHandler()
    logger = logging.getLogger('pgmanager')
    logger.addHandler(handler)
    logger.setLevel(logging.DEBUG)

    dq = DelayedQuery(pgm)
    
    print('add 1')
    dq.add(10, 'INSERT INTO test (name) VALUES (%s)', ['spam1'], queryid=1)
    dq.add(10, 'INSERT INTO test (name) VALUES (%s)', ['spam1'], queryid=1)
    print('after 1')
    
    time.sleep(5)
    
    print('add 2')
    dq.add(10, 'INSERT INTO test (name) VALUES (%s)', ['spam2'])
    
    time.sleep(5)
    print('after 10')

    time.sleep(10)