diff options
| author | Aaron Linville <aaron@linville.org> | 2023-08-17 18:06:25 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2024-02-16 12:59:19 +0100 |
| commit | 7a05b8a2fac57e32a61726893d4601352c1d1c8d (patch) | |
| tree | 186513f0f28bad17ced097853358e72609415ac5 /django/db | |
| parent | 66e47ac69a7e71cf32eee312d05668d8f1ba24bb (diff) | |
Fixed #24018 -- Allowed setting pragma options on SQLite.
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 8e17ea3d44..c7cf947800 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -187,6 +187,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): f"{allowed_transaction_modes}, or None." ) self.transaction_mode = transaction_mode.upper() if transaction_mode else None + + init_command = kwargs.pop("init_command", "") + self.init_commands = init_command.split(";") return kwargs def get_database_version(self): @@ -201,6 +204,9 @@ class DatabaseWrapper(BaseDatabaseWrapper): # The macOS bundled SQLite defaults legacy_alter_table ON, which # prevents atomic table renames. conn.execute("PRAGMA legacy_alter_table = OFF") + for init_command in self.init_commands: + if init_command := init_command.strip(): + conn.execute(init_command) return conn def create_cursor(self, name=None): |
