2004-10-19 07:17:12 +04:00
|
|
|
import datetime
|
2004-11-20 13:57:54 +03:00
|
|
|
import time
|
2005-09-30 20:48:41 +04:00
|
|
|
import psycopg2
|
2004-10-19 07:17:12 +04:00
|
|
|
|
|
|
|
#d = datetime.timedelta(12, 100, 9876)
|
|
|
|
#print d.days, d.seconds, d.microseconds
|
|
|
|
#print psycopg.adapt(d).getquoted()
|
|
|
|
|
2005-11-14 14:57:45 +03:00
|
|
|
conn = psycopg2.connect("dbname=test")
|
|
|
|
#conn.set_client_encoding("xxx")
|
2004-11-20 13:57:54 +03:00
|
|
|
curs = conn.cursor()
|
2005-11-14 14:57:45 +03:00
|
|
|
curs.execute("SELECT '2005-2-12'::date AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '10:23:60'::time AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '10:23:59.895342'::time AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '0:0:12.31423'::time with time zone AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '0:0:12+01:30'::time with time zone AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '2005-2-12 10:23:59.895342'::timestamp AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
curs.execute("SELECT '2005-2-12 10:23:59.895342'::timestamp with time zone AS foo")
|
|
|
|
print curs.fetchall()
|
|
|
|
|
2004-11-20 13:57:54 +03:00
|
|
|
#print curs.fetchmany(2)
|
|
|
|
#print curs.fetchall()
|
|
|
|
|
|
|
|
def sleep(curs):
|
|
|
|
while not curs.isready():
|
|
|
|
print "."
|
|
|
|
time.sleep(.1)
|
2005-11-14 14:57:45 +03:00
|
|
|
|
2004-11-20 13:57:54 +03:00
|
|
|
#curs.execute("""
|
|
|
|
# DECLARE zz INSENSITIVE SCROLL CURSOR WITH HOLD FOR
|
|
|
|
# SELECT now();
|
|
|
|
# FOR READ ONLY;""", async = 1)
|
2005-11-14 14:57:45 +03:00
|
|
|
#curs.execute("SELECT now() AS foo", async=1);
|
|
|
|
#sleep(curs)
|
|
|
|
#print curs.fetchall()
|
2004-11-20 13:57:54 +03:00
|
|
|
|
|
|
|
#curs.execute("""
|
|
|
|
# FETCH FORWARD 1 FROM zz;""", async = 1)
|
2005-11-14 14:57:45 +03:00
|
|
|
#curs.execute("SELECT now() AS bar", async=1);
|
|
|
|
#print curs.fetchall()
|
2004-12-14 06:33:03 +03:00
|
|
|
|
2005-11-14 14:57:45 +03:00
|
|
|
#curs.execute("SELECT now() AS bar");
|
|
|
|
#sleep(curs)
|
2004-12-14 06:33:03 +03:00
|
|
|
|