MCPcopy
hub / github.com/django/django / get_connection_params

Method get_connection_params

django/db/backends/sqlite3/base.py:154–198  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

152 ops_class = DatabaseOperations
153
154 def get_connection_params(self):
155 settings_dict = self.settings_dict
156 if not settings_dict["NAME"]:
157 raise ImproperlyConfigured(
158 "settings.DATABASES is improperly configured. "
159 "Please supply the NAME value."
160 )
161 kwargs = {
162 "database": settings_dict["NAME"],
163 "detect_types": Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES,
164 **settings_dict["OPTIONS"],
165 }
166 # Always allow the underlying SQLite connection to be shareable
167 # between multiple threads. The safe-guarding will be handled at a
168 # higher level by the `BaseDatabaseWrapper.allow_thread_sharing`
169 # property. This is necessary as the shareability is disabled by
170 # default in sqlite3 and it cannot be changed once a connection is
171 # opened.
172 if "check_same_thread" in kwargs and kwargs["check_same_thread"]:
173 warnings.warn(
174 "The `check_same_thread` option was provided and set to "
175 "True. It will be overridden with False. Use the "
176 "`DatabaseWrapper.allow_thread_sharing` property instead "
177 "for controlling thread shareability.",
178 RuntimeWarning,
179 )
180 kwargs.update({"check_same_thread": False, "uri": True})
181 transaction_mode = kwargs.pop("transaction_mode", None)
182 if (
183 transaction_mode is not None
184 and transaction_mode.upper() not in self.transaction_modes
185 ):
186 allowed_transaction_modes = ", ".join(
187 [f"{mode!r}" for mode in sorted(self.transaction_modes)]
188 )
189 raise ImproperlyConfigured(
190 f"settings.DATABASES[{self.alias!r}]['OPTIONS']['transaction_mode'] "
191 f"is improperly configured to '{transaction_mode}'. Use one of "
192 f"{allowed_transaction_modes}, or None."
193 )
194 self.transaction_mode = transaction_mode.upper() if transaction_mode else None
195
196 init_command = kwargs.pop("init_command", "")
197 self.init_commands = init_command.split(";")
198 return kwargs
199
200 def get_database_version(self):
201 return self.Database.sqlite_version_info

Callers

nothing calls this directly

Calls 5

updateMethod · 0.45
popMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected