2005-10-25 19:35:11 +04:00
|
|
|
import psycopg2
|
|
|
|
import psycopg2.extensions
|
|
|
|
|
|
|
|
class Portal(psycopg2.extensions.cursor):
|
|
|
|
def __init__(self, name, curs):
|
2005-10-25 20:00:49 +04:00
|
|
|
psycopg2.extensions.cursor.__init__(
|
|
|
|
self, curs.connection, '"'+name+'"')
|
2005-10-25 19:35:11 +04:00
|
|
|
|
|
|
|
CURSOR = psycopg2.extensions.new_type((1790,), "CURSOR", Portal)
|
|
|
|
psycopg2.extensions.register_type(CURSOR)
|
|
|
|
|
|
|
|
conn = psycopg2.connect("dbname=test")
|
|
|
|
|
|
|
|
curs = conn.cursor()
|
|
|
|
curs.execute("SELECT reffunc2()")
|
2005-10-25 20:00:49 +04:00
|
|
|
|
2005-10-25 19:35:11 +04:00
|
|
|
portal = curs.fetchone()[0]
|
|
|
|
print portal.fetchone()
|
2005-10-25 20:00:49 +04:00
|
|
|
print portal.fetchmany(2)
|
|
|
|
portal.scroll(0, 'absolute')
|
2005-10-25 19:35:11 +04:00
|
|
|
print portal.fetchall()
|
|
|
|
|
|
|
|
|
|
|
|
#print curs.rowcount
|
|
|
|
#print curs.statusmessage
|
|
|
|
#print curs.fetchone()
|
|
|
|
#print curs.rowcount
|
|
|
|
#print curs.statusmessage
|
|
|
|
#print curs.fetchone()
|
|
|
|
#print curs.rowcount
|
|
|
|
#print curs.statusmessage
|