Sandbox stuff (not distributed but can help others to debug.)

This commit is contained in:
Federico Di Gregorio 2006-06-07 23:46:32 +00:00
parent 0544e96812
commit 267b4171ec
3 changed files with 41 additions and 0 deletions

18
sandbox/domainoid.py Normal file
View File

@ -0,0 +1,18 @@
import psycopg2
con = psycopg2.connect("dbname=test")
cur = con.cursor()
cur.execute("SELECT %s::regtype::oid", ('bytea', ))
print cur.fetchone()[0]
# 17
cur.execute("CREATE DOMAIN thing AS bytea")
cur.execute("SELECT %s::regtype::oid", ('thing', ))
print cur.fetchone()[0]
#62148
cur.execute("CREATE TABLE thingrel (thingcol thing)")
cur.execute("SELECT * FROM thingrel")
print cur.description
#(('thingcol', 17, None, -1, None, None, None),)

14
sandbox/iter.py Normal file
View File

@ -0,0 +1,14 @@
import psycopg2
import psycopg2.extras
conn = psycopg2.connect("dbname=test")
curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
curs.execute("SELECT '2005-2-12'::date AS foo, 'boo!' as bar")
for x in curs.fetchall():
print type(x), x[0], x[1], x['foo'], x['bar']
curs.execute("SELECT '2005-2-12'::date AS foo, 'boo!' as bar")
for x in curs:
print type(x), x[0], x[1], x['foo'], x['bar']

9
sandbox/test814.py Normal file
View File

@ -0,0 +1,9 @@
import psycopg2
import psycopg2.extras
conn = psycopg2.connect("dbname=test")
curs = conn.cursor()
curs.execute("SELECT true AS foo WHERE 'a' in %s", (("aa", "bb"),))
print curs.fetchall()
print curs.query