Mikhail Denisenko avatar Mikhail Denisenko committed 57e693d

added mars and load_balancer options

Comments (0)

Files changed (1)

django_pytds/base.py

         except ValueError:
             self.cast_avg_to_float = False
 
-    def __connect(self):
-        """Connect to the database"""
-        self.connection = Database.connect(
-            server=self.settings_dict['HOST'],
-            database=self.settings_dict['NAME'],
-            user=self.settings_dict['USER'],
-            password=self.settings_dict['PASSWORD'],
-            timeout=self.command_timeout,
-            autocommit=self.autocommit,
-        )
-        # The OUTPUT clause is supported in 2005+ sql servers
-        self.features.can_return_id_from_insert = self.connection.tds_version >= Database.TDS72
-
-        connection_created.send(sender=self.__class__, connection=self)
-        return self.connection
-
     def _cursor(self):
         if self.connection is None:
-            self.__connect()
+            """Connect to the database"""
+            options = self.settings_dict.get('OPTIONS', {})
+            self.connection = Database.connect(
+                server=self.settings_dict['HOST'],
+                database=self.settings_dict['NAME'],
+                user=self.settings_dict['USER'],
+                password=self.settings_dict['PASSWORD'],
+                timeout=self.command_timeout,
+                autocommit=self.autocommit,
+                use_mars=options.get('use_mars', False),
+                load_balancer=options.get('load_balancer', None),
+            )
+            # The OUTPUT clause is supported in 2005+ sql servers
+            self.features.can_return_id_from_insert = self.connection.tds_version >= Database.TDS72
+            connection_created.send(sender=self.__class__, connection=self)
         return CursorWrapper(self.connection.cursor())
 
     def disable_constraint_checking(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.