diff options
Diffstat (limited to 'django/db/backends/base/base.py')
| -rw-r--r-- | django/db/backends/base/base.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py index 96ca0ccfde..2e6a528171 100644 --- a/django/db/backends/base/base.py +++ b/django/db/backends/base/base.py @@ -1,3 +1,4 @@ +import copy import time import warnings from collections import deque @@ -622,3 +623,16 @@ class BaseDatabaseWrapper(object): func() finally: self.run_on_commit = [] + + def copy(self, alias=None, allow_thread_sharing=None): + """ + Return a copy of this connection. + + For tests that require two connections to the same database. + """ + settings_dict = copy.deepcopy(self.settings_dict) + if alias is None: + alias = self.alias + if allow_thread_sharing is None: + allow_thread_sharing = self.allow_thread_sharing + return type(self)(settings_dict, alias, allow_thread_sharing) |
