Is it possible to set SQL Server query timeout within Django/South?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have a Django app that I have just migrated to South for model/DB synchronization. I have created a new migration after making some changes to the model (ie. adding a new foreign key field). Here is a sample of the code within the new migration
0002_auto__add_field_table_new_field.py
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Table.new_field'
db.add_column(u'Table', 'new_field',
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['database.other_table'], null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Table.new_field'
db.delete_column(u'Table', 'new_field')
When I attempt to apply the migration the query always times out after roughly 30 seconds, with the following error message:
sqlserver_ado,dbapi.DatabaseError: (-2147352567, 'Exception occured.', (0, u'Microsoft SQL Server Native Client 10.0', u'Query timeout expired', None, 0, -2147217871), None)
Is it possible to increase the SQL Server query timeout? I have been unable to find any specific documentation on this other than how to increase the value within SSMS, but having done this it has made no difference. Is this perhaps done in Django settings.py?
python sql

add a comment |
I have a Django app that I have just migrated to South for model/DB synchronization. I have created a new migration after making some changes to the model (ie. adding a new foreign key field). Here is a sample of the code within the new migration
0002_auto__add_field_table_new_field.py
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Table.new_field'
db.add_column(u'Table', 'new_field',
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['database.other_table'], null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Table.new_field'
db.delete_column(u'Table', 'new_field')
When I attempt to apply the migration the query always times out after roughly 30 seconds, with the following error message:
sqlserver_ado,dbapi.DatabaseError: (-2147352567, 'Exception occured.', (0, u'Microsoft SQL Server Native Client 10.0', u'Query timeout expired', None, 0, -2147217871), None)
Is it possible to increase the SQL Server query timeout? I have been unable to find any specific documentation on this other than how to increase the value within SSMS, but having done this it has made no difference. Is this perhaps done in Django settings.py?
python sql

add a comment |
I have a Django app that I have just migrated to South for model/DB synchronization. I have created a new migration after making some changes to the model (ie. adding a new foreign key field). Here is a sample of the code within the new migration
0002_auto__add_field_table_new_field.py
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Table.new_field'
db.add_column(u'Table', 'new_field',
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['database.other_table'], null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Table.new_field'
db.delete_column(u'Table', 'new_field')
When I attempt to apply the migration the query always times out after roughly 30 seconds, with the following error message:
sqlserver_ado,dbapi.DatabaseError: (-2147352567, 'Exception occured.', (0, u'Microsoft SQL Server Native Client 10.0', u'Query timeout expired', None, 0, -2147217871), None)
Is it possible to increase the SQL Server query timeout? I have been unable to find any specific documentation on this other than how to increase the value within SSMS, but having done this it has made no difference. Is this perhaps done in Django settings.py?
python sql

I have a Django app that I have just migrated to South for model/DB synchronization. I have created a new migration after making some changes to the model (ie. adding a new foreign key field). Here is a sample of the code within the new migration
0002_auto__add_field_table_new_field.py
class Migration(SchemaMigration):
def forwards(self, orm):
# Adding field 'Table.new_field'
db.add_column(u'Table', 'new_field',
self.gf('django.db.models.fields.related.ForeignKey')(to=orm['database.other_table'], null=True, blank=True),
keep_default=False)
def backwards(self, orm):
# Deleting field 'Table.new_field'
db.delete_column(u'Table', 'new_field')
When I attempt to apply the migration the query always times out after roughly 30 seconds, with the following error message:
sqlserver_ado,dbapi.DatabaseError: (-2147352567, 'Exception occured.', (0, u'Microsoft SQL Server Native Client 10.0', u'Query timeout expired', None, 0, -2147217871), None)
Is it possible to increase the SQL Server query timeout? I have been unable to find any specific documentation on this other than how to increase the value within SSMS, but having done this it has made no difference. Is this perhaps done in Django settings.py?
python sql

python sql

asked Nov 7 '13 at 16:01


giogoicegiogoice
217
217
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
So it turns out that the problem was being caused by the backend python db module sqlserver_ado. It is this module that was determining the query timeout. I have amended my settings.py to now use the sql_server.pyodbc ENGINE instead. The migration has now been applied successfully by making use of this.
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
add a comment |
If you need to stick with the sqlserver_ado driver, you can set query timeout as described in this question (default is 30 s):
Query timeout expired in django-mssql when executing custom SQL directly
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'ENGINE': 'sqlserver_ado',
'HOST': DATABASE_HOST,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'COMMAND_TIMEOUT': timeout_in_seconds,
}
}
add a comment |
This question is a bit old, but it's what comes up at the top of Google's results, so I'd like to add for those coming along later that if you use pyodbc with django-pyodbc (specifically django-pyodbc-azure for more modern Django), there are several settings that may be of interest; note especially the query_timeout
setting:
connection_timeout
Integer. Sets the timeout in seconds for the database connection process. Default value is 0 which disables the timeout.
connection_retries
Integer. Sets the times to retry the database connection process. Default value is 5.
connection_retry_backoff_time
Integer. Sets the back off time in seconds for reries of the database connection process. Default value is 5.
query_timeout
Integer. Sets the timeout in seconds for the database query. Default value is 0 which disables the timeout.
Adding the query_timeout
setting to the database options allowed me to work around an issue that was occurring to a db lock (where the write my code was doing wasn't currently important):
DATABASES = {
'default': {
# ...
'OPTIONS': {
'driver': 'FreeTDS',
'query_timeout': 6,
},
},
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19840641%2fis-it-possible-to-set-sql-server-query-timeout-within-django-south%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
So it turns out that the problem was being caused by the backend python db module sqlserver_ado. It is this module that was determining the query timeout. I have amended my settings.py to now use the sql_server.pyodbc ENGINE instead. The migration has now been applied successfully by making use of this.
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
add a comment |
So it turns out that the problem was being caused by the backend python db module sqlserver_ado. It is this module that was determining the query timeout. I have amended my settings.py to now use the sql_server.pyodbc ENGINE instead. The migration has now been applied successfully by making use of this.
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
add a comment |
So it turns out that the problem was being caused by the backend python db module sqlserver_ado. It is this module that was determining the query timeout. I have amended my settings.py to now use the sql_server.pyodbc ENGINE instead. The migration has now been applied successfully by making use of this.
So it turns out that the problem was being caused by the backend python db module sqlserver_ado. It is this module that was determining the query timeout. I have amended my settings.py to now use the sql_server.pyodbc ENGINE instead. The migration has now been applied successfully by making use of this.
answered Nov 8 '13 at 15:57


giogoicegiogoice
217
217
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
add a comment |
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
Hi, I'm having a similar problem in that I want to change the timeout. Were you using django-mssql? How did you use pyodbc with django?
– user193130
Dec 10 '14 at 23:34
add a comment |
If you need to stick with the sqlserver_ado driver, you can set query timeout as described in this question (default is 30 s):
Query timeout expired in django-mssql when executing custom SQL directly
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'ENGINE': 'sqlserver_ado',
'HOST': DATABASE_HOST,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'COMMAND_TIMEOUT': timeout_in_seconds,
}
}
add a comment |
If you need to stick with the sqlserver_ado driver, you can set query timeout as described in this question (default is 30 s):
Query timeout expired in django-mssql when executing custom SQL directly
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'ENGINE': 'sqlserver_ado',
'HOST': DATABASE_HOST,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'COMMAND_TIMEOUT': timeout_in_seconds,
}
}
add a comment |
If you need to stick with the sqlserver_ado driver, you can set query timeout as described in this question (default is 30 s):
Query timeout expired in django-mssql when executing custom SQL directly
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'ENGINE': 'sqlserver_ado',
'HOST': DATABASE_HOST,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'COMMAND_TIMEOUT': timeout_in_seconds,
}
}
If you need to stick with the sqlserver_ado driver, you can set query timeout as described in this question (default is 30 s):
Query timeout expired in django-mssql when executing custom SQL directly
DATABASES = {
'default': {
'NAME': DATABASE_NAME,
'ENGINE': 'sqlserver_ado',
'HOST': DATABASE_HOST,
'USER': DATABASE_USER,
'PASSWORD': DATABASE_PASSWORD,
'COMMAND_TIMEOUT': timeout_in_seconds,
}
}
edited May 23 '17 at 11:52
Community♦
11
11
answered Jan 17 '16 at 22:05
Mr. NapikMr. Napik
3,88531818
3,88531818
add a comment |
add a comment |
This question is a bit old, but it's what comes up at the top of Google's results, so I'd like to add for those coming along later that if you use pyodbc with django-pyodbc (specifically django-pyodbc-azure for more modern Django), there are several settings that may be of interest; note especially the query_timeout
setting:
connection_timeout
Integer. Sets the timeout in seconds for the database connection process. Default value is 0 which disables the timeout.
connection_retries
Integer. Sets the times to retry the database connection process. Default value is 5.
connection_retry_backoff_time
Integer. Sets the back off time in seconds for reries of the database connection process. Default value is 5.
query_timeout
Integer. Sets the timeout in seconds for the database query. Default value is 0 which disables the timeout.
Adding the query_timeout
setting to the database options allowed me to work around an issue that was occurring to a db lock (where the write my code was doing wasn't currently important):
DATABASES = {
'default': {
# ...
'OPTIONS': {
'driver': 'FreeTDS',
'query_timeout': 6,
},
},
}
add a comment |
This question is a bit old, but it's what comes up at the top of Google's results, so I'd like to add for those coming along later that if you use pyodbc with django-pyodbc (specifically django-pyodbc-azure for more modern Django), there are several settings that may be of interest; note especially the query_timeout
setting:
connection_timeout
Integer. Sets the timeout in seconds for the database connection process. Default value is 0 which disables the timeout.
connection_retries
Integer. Sets the times to retry the database connection process. Default value is 5.
connection_retry_backoff_time
Integer. Sets the back off time in seconds for reries of the database connection process. Default value is 5.
query_timeout
Integer. Sets the timeout in seconds for the database query. Default value is 0 which disables the timeout.
Adding the query_timeout
setting to the database options allowed me to work around an issue that was occurring to a db lock (where the write my code was doing wasn't currently important):
DATABASES = {
'default': {
# ...
'OPTIONS': {
'driver': 'FreeTDS',
'query_timeout': 6,
},
},
}
add a comment |
This question is a bit old, but it's what comes up at the top of Google's results, so I'd like to add for those coming along later that if you use pyodbc with django-pyodbc (specifically django-pyodbc-azure for more modern Django), there are several settings that may be of interest; note especially the query_timeout
setting:
connection_timeout
Integer. Sets the timeout in seconds for the database connection process. Default value is 0 which disables the timeout.
connection_retries
Integer. Sets the times to retry the database connection process. Default value is 5.
connection_retry_backoff_time
Integer. Sets the back off time in seconds for reries of the database connection process. Default value is 5.
query_timeout
Integer. Sets the timeout in seconds for the database query. Default value is 0 which disables the timeout.
Adding the query_timeout
setting to the database options allowed me to work around an issue that was occurring to a db lock (where the write my code was doing wasn't currently important):
DATABASES = {
'default': {
# ...
'OPTIONS': {
'driver': 'FreeTDS',
'query_timeout': 6,
},
},
}
This question is a bit old, but it's what comes up at the top of Google's results, so I'd like to add for those coming along later that if you use pyodbc with django-pyodbc (specifically django-pyodbc-azure for more modern Django), there are several settings that may be of interest; note especially the query_timeout
setting:
connection_timeout
Integer. Sets the timeout in seconds for the database connection process. Default value is 0 which disables the timeout.
connection_retries
Integer. Sets the times to retry the database connection process. Default value is 5.
connection_retry_backoff_time
Integer. Sets the back off time in seconds for reries of the database connection process. Default value is 5.
query_timeout
Integer. Sets the timeout in seconds for the database query. Default value is 0 which disables the timeout.
Adding the query_timeout
setting to the database options allowed me to work around an issue that was occurring to a db lock (where the write my code was doing wasn't currently important):
DATABASES = {
'default': {
# ...
'OPTIONS': {
'driver': 'FreeTDS',
'query_timeout': 6,
},
},
}
answered Jan 3 at 4:23
hlongmorehlongmore
7581321
7581321
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f19840641%2fis-it-possible-to-set-sql-server-query-timeout-within-django-south%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown