Put this in a base.py file.
And config this settings:
DATABASE_ENGINE = 'path.to.module.with.base.file' DATABASE_STATEMENT_TIMEOUT = 60000 # milliseconds
(Idea from: http://www.mailinglistarchive.com/html/[email protected]/2009-02/msg00024.html)
1 2 3 4 5 6 7 8 9 10 11 12 | # base.py
from django.db.backends.postgresql_psycopg2.base import *
from django.conf import settings
class DatabaseWrapper(DatabaseWrapper):
def _cursor(self):
cursor = super(DatabaseWrapper, self)._cursor()
statement_timeout = getattr(settings, 'DATABASE_STATEMENT_TIMEOUT', None)
if statement_timeout is not None:
cursor.execute("SET STATEMENT_TIMEOUT=%s" % statement_timeout)
return cursor
|
More like this
- Form field with fixed value by roam 3 days, 14 hours ago
- New Snippet! by Antoliny0919 1 week, 3 days ago
- Add Toggle Switch Widget to Django Forms by OgliariNatan 2 months, 4 weeks ago
- get_object_or_none by azwdevops 6 months, 3 weeks ago
- Mask sensitive data from logger by agusmakmun 8 months, 2 weeks ago
Comments
Please login first before commenting.