summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2006-06-07 23:46:32 +0000
committerFederico Di Gregorio <fog@initd.org>2006-06-07 23:46:32 +0000
commit267b4171ec5802f67a3a656f8a9f25d1cd2b8824 (patch)
tree8fb7052a3d8927f71f184bb8432eff4f0258b61c
parent0544e968124e488d0397bb3898dd9dd3d272ba4d (diff)
downloadpsycopg2-267b4171ec5802f67a3a656f8a9f25d1cd2b8824.tar.gz
Sandbox stuff (not distributed but can help others to debug.)
-rw-r--r--sandbox/domainoid.py18
-rw-r--r--sandbox/iter.py14
-rw-r--r--sandbox/test814.py9
3 files changed, 41 insertions, 0 deletions
diff --git a/sandbox/domainoid.py b/sandbox/domainoid.py
new file mode 100644
index 0000000..0d98399
--- /dev/null
+++ b/sandbox/domainoid.py
@@ -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),)
diff --git a/sandbox/iter.py b/sandbox/iter.py
new file mode 100644
index 0000000..74c8aba
--- /dev/null
+++ b/sandbox/iter.py
@@ -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']
+
diff --git a/sandbox/test814.py b/sandbox/test814.py
new file mode 100644
index 0000000..53e7e7f
--- /dev/null
+++ b/sandbox/test814.py
@@ -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
+