summaryrefslogtreecommitdiff
path: root/django/db
diff options
context:
space:
mode:
Diffstat (limited to 'django/db')
-rw-r--r--django/db/backends/sqlite3/base.py6
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):