@@ -97,9 +97,11 @@ def __init__(self, *args, **kwargs):
97
self .validation = BaseDatabaseValidation ()
97
self .validation = BaseDatabaseValidation ()
98
98
99
def _cursor (self ):
99
def _cursor (self ):
100
+ new_connection = False
100
set_tz = False
101
set_tz = False
101
settings_dict = self .settings_dict
102
settings_dict = self .settings_dict
102
if self .connection is None :
103
if self .connection is None :
104
+ new_connection = True
103
set_tz = settings_dict .get ('TIME_ZONE' )
105
set_tz = settings_dict .get ('TIME_ZONE' )
104
if settings_dict ['DATABASE_NAME' ] == '' :
106
if settings_dict ['DATABASE_NAME' ] == '' :
105
from django .core .exceptions import ImproperlyConfigured
107
from django .core .exceptions import ImproperlyConfigured
@@ -117,8 +119,9 @@ def _cursor(self):
117
self .connection .set_isolation_level (1 ) # make transactions transparent to all cursors
119
self .connection .set_isolation_level (1 ) # make transactions transparent to all cursors
118
connection_created .send (sender = self .__class__ )
120
connection_created .send (sender = self .__class__ )
119
cursor = self .connection .cursor ()
121
cursor = self .connection .cursor ()
120
- if set_tz :
122
+ if new_connection :
121
- cursor .execute ("SET TIME ZONE %s" , [settings_dict ['TIME_ZONE' ]])
123
+ if set_tz :
124
+ cursor .execute ("SET TIME ZONE %s" , [settings_dict ['TIME_ZONE' ]])
122
if not hasattr (self , '_version' ):
125
if not hasattr (self , '_version' ):
123
self .__class__ ._version = get_version (cursor )
126
self .__class__ ._version = get_version (cursor )
124
if self ._version [0 :2 ] < (8 , 0 ):
127
if self ._version [0 :2 ] < (8 , 0 ):
0 commit comments