From 728b4788de8b70bf809103e944e84c02d8ba608b Mon Sep 17 00:00:00 2001 From: Federico Di Gregorio Date: Sun, 3 Apr 2005 06:16:24 +0000 Subject: [PATCH] psycopg1 compatibility module (added autocommit.) --- ChangeLog | 3 +++ lib/psycopg1.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 693ade79..a00c3c76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-04-03 Federico Di Gregorio + * lib/psycopg1.py (connection.autocommit): added compatibility + .autocommit() method. + * psycopg/psycopgmodule.c (psyco_connect): factory -> connection_factory. diff --git a/lib/psycopg1.py b/lib/psycopg1.py index 45a1783b..09b6e843 100644 --- a/lib/psycopg1.py +++ b/lib/psycopg1.py @@ -41,6 +41,13 @@ class connection(_2connection): """cursor() -> new psycopg 1.1.x compatible cursor object""" return _2connection.cursor(self, cursor_factory=cursor) + def autocommit(self, on_off=1): + """autocommit(on_off=1) -> switch autocommit on (1) or off (0)""" + if on_off > 0: + self.set_isolation_level(0) + else: + self.set_isolation_level(2) + class cursor(_2cursor): """psycopg 1.1.x cursor. @@ -73,4 +80,4 @@ class cursor(_2cursor): for row in rows: res.append(self.__build_dict(row)) return res - +