Using psycopg cursor in a product
Hi all, Is it possible to use cursors and their functions (dictfetchall, fetchone...) with zpsycopg connection ? Thanks, Fred. -- Frederic de ZORZI - PimenTech http://www.pimentech.net
Hi all, Is it possible to use cursors and their functions (dictfetchall, fetchone...) with zpsycopg connection ?
Easy stupid :) : conn = getattr(self, self.connection_id) db = conn().db curs = db.cursor() curs.execute("select * from support limit 2") return "%s" % curs.dictfetchall() Now, how about managing transactions ?
Il ven, 2002-02-08 alle 12:47, de ZORZI Frederic ha scritto:
Hi all, Is it possible to use cursors and their functions (dictfetchall, fetchone...) with zpsycopg connection ?
Easy stupid :) :
conn = getattr(self, self.connection_id) db = conn().db
curs = db.cursor() curs.execute("select * from support limit 2") return "%s" % curs.dictfetchall()
Now, how about managing transactions ?
zope manages them for you. you get a commit() at the end of the page and a rollback() in case of an uncatched exception. if you want to do transaction management yourself, create your own connection/cursor in an external method. ciao, federico -- Federico Di Gregorio Debian GNU/Linux Developer & Italian Press Contact fog@debian.org INIT.D Developer fog@initd.org One key. One input. One enter. All right. -- An american consultant (then the system crashed and took down the *entire* network)
participants (2)
-
de ZORZI Frederic -
Federico Di Gregorio