mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 08:56:34 +03:00
Sandbox stuff (not distributed but can help others to debug.)
This commit is contained in:
parent
0544e96812
commit
267b4171ec
18
sandbox/domainoid.py
Normal file
18
sandbox/domainoid.py
Normal 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
14
sandbox/iter.py
Normal 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
9
sandbox/test814.py
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user