psycopg1 compatibility module (added autocommit.)

This commit is contained in:
Federico Di Gregorio 2005-04-03 06:16:24 +00:00
parent fdb68599c7
commit 728b4788de
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2005-04-03 Federico Di Gregorio <fog@debian.org> 2005-04-03 Federico Di Gregorio <fog@debian.org>
* lib/psycopg1.py (connection.autocommit): added compatibility
.autocommit() method.
* psycopg/psycopgmodule.c (psyco_connect): factory -> * psycopg/psycopgmodule.c (psyco_connect): factory ->
connection_factory. connection_factory.

View File

@ -41,6 +41,13 @@ class connection(_2connection):
"""cursor() -> new psycopg 1.1.x compatible cursor object""" """cursor() -> new psycopg 1.1.x compatible cursor object"""
return _2connection.cursor(self, cursor_factory=cursor) 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): class cursor(_2cursor):
"""psycopg 1.1.x cursor. """psycopg 1.1.x cursor.