diff --git a/django/core/management.py b/django/core/management.py index 01739f6e1f..c2f56eb676 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -1542,6 +1542,8 @@ def print_error(msg, cmd): sys.exit(1) def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING, argv=None): + from django.db import backend + # Use sys.argv if we've not passed in a custom argv if argv is None: argv = sys.argv @@ -1652,7 +1654,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING, argv=None): if not mod_list: parser.print_usage_and_exit() if action not in NO_SQL_TRANSACTION: - print style.SQL_KEYWORD("BEGIN;") + print style.SQL_KEYWORD(backend.get_start_transaction_sql()) for mod in mod_list: if action == 'reset': output = action_mapping[action](mod, options.interactive) diff --git a/django/db/backends/ado_mssql/base.py b/django/db/backends/ado_mssql/base.py index 220331480b..6c24912e22 100644 --- a/django/db/backends/ado_mssql/base.py +++ b/django/db/backends/ado_mssql/base.py @@ -149,6 +149,9 @@ def get_pk_default_value(): def get_max_name_length(): return None +def get_start_transaction_sql(): + return "BEGIN;" + def get_autoinc_sql(table): return None diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index 5767eaed51..4af4cdb0d6 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -194,6 +194,9 @@ def get_pk_default_value(): def get_max_name_length(): return 64; +def get_start_transaction_sql(): + return "BEGIN;" + def get_autoinc_sql(table): return None diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index fd8c8dde14..90a601ace7 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -168,6 +168,9 @@ def get_pk_default_value(): def get_max_name_length(): return 30 +def get_start_transaction_sql(): + return "" + def get_autoinc_sql(table): # To simulate auto-incrementing primary keys in Oracle, we have to # create a sequence and a trigger. diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 340fd54710..e5a7893cc7 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -169,6 +169,9 @@ def get_pk_default_value(): def get_max_name_length(): return None +def get_start_transaction_sql(): + return "BEGIN;" + def get_autoinc_sql(table): return None diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 654b31c6b8..cc67b306a9 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -129,6 +129,9 @@ def get_pk_default_value(): def get_max_name_length(): return None +def get_start_transaction_sql(): + return "BEGIN;" + def get_autoinc_sql(table): return None diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index f2e602e17d..3f5c796843 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -163,6 +163,9 @@ def get_pk_default_value(): def get_max_name_length(): return None +def get_start_transaction_sql(): + return "BEGIN;" + def get_autoinc_sql(table): return None