Ticket #3460: psycopg2-commit-mode-r5790.diff
File psycopg2-commit-mode-r5790.diff, 1.5 KB (added by , 17 years ago) |
---|
-
db/backends/postgresql_psycopg2/base.py
34 34 35 35 def cursor(self): 36 36 from django.conf import settings 37 set_tz= False37 first_cursor = False 38 38 if self.connection is None: 39 set_tz= True39 first_cursor = True 40 40 if settings.DATABASE_NAME == '': 41 41 from django.core.exceptions import ImproperlyConfigured 42 42 raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file." … … 50 50 if settings.DATABASE_PORT: 51 51 conn_string += " port=%s" % settings.DATABASE_PORT 52 52 self.connection = Database.connect(conn_string, **self.options) 53 self.connection.set_isolation_level( 1) # make transactions transparent to all cursors53 self.connection.set_isolation_level(0) # autocommit 54 54 self.connection.set_client_encoding('UTF8') 55 55 cursor = self.connection.cursor() 56 56 cursor.tzinfo_factory = None 57 if set_tz:57 if first_cursor: 58 58 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 59 cursor.execute("SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED") 60 self._commit() 59 61 global postgres_version 60 62 if not postgres_version: 61 63 cursor.execute("SELECT version()")