psycopg2/sandbox/test.py

37 lines
834 B
Python
Raw Normal View History

import datetime
2004-11-20 13:57:54 +03:00
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")
2004-11-20 13:57:54 +03:00
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)
2004-12-14 06:33:03 +03:00
print curs.fetchall()
2004-11-20 13:57:54 +03:00
#curs.execute("""
# FETCH FORWARD 1 FROM zz;""", async = 1)
curs.execute("SELECT now() AS bar", async=1);
2004-12-14 06:33:03 +03:00
print curs.fetchall()
curs.execute("SELECT now() AS bar");
2004-11-20 13:57:54 +03:00
sleep(curs)
2004-12-14 06:33:03 +03:00