File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,16 @@ Dictionary. Current available keys are:
128128 See http://msdn.microsoft.com/en-us/library/ms130892.aspx. Default is
129129 ``"SQL Server" `` on Windows and ``"FreeTDS" `` on other platforms.
130130
131+ - isolation_level
132+
133+ String. Sets `transaction isolation level
134+ <https://docs.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level-transact-sql> `__
135+ for each database session. Valid values for this entry are
136+ ``READ UNCOMMITTED ``, ``READ COMMITTED ``, ``REPEATABLE READ ``,
137+ ``SNAPSHOT ``, and ``SERIALIZABLE ``. Default is ``None `` which means
138+ no isolation levei is set to a database session and SQL Server default
139+ will be used.
140+
131141- dsn
132142
133143 String. A named DSN can be used instead of ``HOST ``.
Original file line number Diff line number Diff line change @@ -361,11 +361,15 @@ def init_connection_state(self):
361361 settings_dict = self .settings_dict
362362 cursor = self .create_cursor ()
363363
364+ options = settings_dict .get ('OPTIONS' , {})
365+ isolation_level = options .get ('isolation_level' , None )
366+ if isolation_level :
367+ cursor .execute ('SET TRANSACTION ISOLATION LEVEL %s' % isolation_level )
368+
364369 # Set date format for the connection. Also, make sure Sunday is
365370 # considered the first day of the week (to be consistent with the
366371 # Django convention for the 'week_day' Django lookup) if the user
367372 # hasn't told us otherwise
368- options = settings_dict .get ('OPTIONS' , {})
369373 datefirst = options .get ('datefirst' , 7 )
370374 cursor .execute ('SET DATEFORMAT ymd; SET DATEFIRST %s' % datefirst )
371375
You can’t perform that action at this time.
0 commit comments