diff options
author | Federico Di Gregorio <fog@initd.org> | 2005-11-28 03:44:14 +0000 |
---|---|---|
committer | Federico Di Gregorio <fog@initd.org> | 2005-11-28 03:44:14 +0000 |
commit | 8ffafd75eb1ad03393891b8c86cf34d662a8ed1b (patch) | |
tree | e296fc6b4a100bffcb34867ea8b484621845614d /sandbox/async.py | |
parent | ad76b5ba3cc01b658e31fb3c4e94340ba0f884d9 (diff) | |
download | psycopg2-8ffafd75eb1ad03393891b8c86cf34d662a8ed1b.tar.gz |
Added sandbox stuff to the repository.
Diffstat (limited to 'sandbox/async.py')
-rw-r--r-- | sandbox/async.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sandbox/async.py b/sandbox/async.py new file mode 100644 index 0000000..17e96d0 --- /dev/null +++ b/sandbox/async.py @@ -0,0 +1,36 @@ +import datetime +import time +import psycopg2 + +#d = datetime.timedelta(12, 100, 9876) +#print d.days, d.seconds, d.microseconds +#print psycopg.adapt(d).getquoted() + +conn = psycopg2.connect("dbname=test_unicode") +conn.set_client_encoding("xxx") +curs = conn.cursor() +#curs.execute("SELECT 1.0 AS foo") +#print curs.fetchmany(2) +#print curs.fetchall() + +def sleep(curs): + while not curs.isready(): + print "." + time.sleep(.1) + +#curs.execute(""" +# DECLARE zz INSENSITIVE SCROLL CURSOR WITH HOLD FOR +# SELECT now(); +# FOR READ ONLY;""", async = 1) +curs.execute("SELECT now() AS foo", async=1); +sleep(curs) +print curs.fetchall() + +#curs.execute(""" +# FETCH FORWARD 1 FROM zz;""", async = 1) +curs.execute("SELECT now() AS bar", async=1); +print curs.fetchall() + +curs.execute("SELECT now() AS bar"); +sleep(curs) + |