summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
+