Ticket #3460: 3460-autocommit.diff
File 3460-autocommit.diff, 2.8 KB (added by , 17 years ago) |
---|
-
django/db/backends/postgresql_psycopg2/base.py
51 51 } 52 52 53 53 def _cursor(self, settings): 54 set_tz= False54 first_cursor = False 55 55 if self.connection is None: 56 set_tz= True56 first_cursor = True 57 57 if settings.DATABASE_NAME == '': 58 58 from django.core.exceptions import ImproperlyConfigured 59 59 raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.") … … 67 67 if settings.DATABASE_PORT: 68 68 conn_string += " port=%s" % settings.DATABASE_PORT 69 69 self.connection = Database.connect(conn_string, **self.options) 70 self.connection.set_isolation_level( 1) # make transactions transparent to all cursors70 self.connection.set_isolation_level(0) # make transactions transparent to all cursors 71 71 self.connection.set_client_encoding('UTF8') 72 72 cursor = self.connection.cursor() 73 73 cursor.tzinfo_factory = None 74 if set_tz:74 if first_cursor: 75 75 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 76 cursor.execute("SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ COMMITTED") 77 self._commit() 76 78 return cursor -
django/core/management/commands/loaddata.py
9 9 except NameError: 10 10 from sets import Set as set # Python 2.3 fallback 11 11 12 def _set_transaction_mode(connection): 13 "Make sure a connection is not in autocommit mode." 14 if hasattr(connection.connection, "autocommit"): 15 connection.connection.autocommit(False) 16 elif hasattr(connection.connection, "set_isolation_level"): 17 connection.connection.set_isolation_level(1) 18 12 19 class Command(BaseCommand): 13 20 option_list = BaseCommand.option_list + ( 14 21 make_option('--verbosity', action='store', dest='verbosity', default='1', … … 40 47 # the side effect of initializing the test database (if 41 48 # it isn't already initialized). 42 49 cursor = connection.cursor() 50 _set_transaction_mode(connection) 43 51 44 52 # Start transaction management. All fixtures are installed in a 45 53 # single transaction to ensure that all references are resolved. … … 129 137 130 138 transaction.commit() 131 139 transaction.leave_transaction_management() 140 connection.close() 132 141 133 142 if object_count == 0: 134 143 if verbosity >= 2: