Re: [Zope-dev] Using psycopg cursor in a product

2002-02-08 Thread de ZORZI Frederic

 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-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Using psycopg cursor in a product

2002-02-08 Thread Federico Di Gregorio

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[EMAIL PROTECTED]
INIT.D Developer   [EMAIL PROTECTED]
 One key. One input. One enter. All right. -- An american consultant
   (then the system crashed and took down the *entire* network)



msg09360/pgp0.pgp
Description: PGP signature