[Zope-dev] Using psycopg cursor in a product
Federico Di Gregorio
fog@debian.org
08 Feb 2002 13:19:24 +0100
--=-8u7nnk3JSjpn80+/BKus
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
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,=20
> > fetchone...) with zpsycopg connection ?
> >=20
>=20
> Easy stupid :) :
>=20
> conn =3D getattr(self, self.connection_id)
> db =3D conn().db
> =09
> curs =3D db.cursor()
> curs.execute("select * from support limit 2")
> return "%s" % curs.dictfetchall()
>=20
>=20
> 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
--=20
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)
--=-8u7nnk3JSjpn80+/BKus
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Per informazioni si veda http://www.gnupg.org
iEYEABECAAYFAjxjwkwACgkQvcCgrgZGjevsBwCgmP+D9blZWdxZfFkNJamc6L6V
3IAAn3DfY0tmf6yDCYCI7xRlA+k7TfqS
=0nrS
-----END PGP SIGNATURE-----
--=-8u7nnk3JSjpn80+/BKus--