summaryrefslogtreecommitdiff
path: root/django/db/backends/sqlite3
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2006-09-05 13:32:08 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2006-09-05 13:32:08 +0000
commit6f87b17a0d0da75767d0bbf05d52f787e897c599 (patch)
tree98583716fe36100c8b9e82e31325993d3b4f382b /django/db/backends/sqlite3
parent6417d6c7c3e439253b0188a61e5bcd0dd5063bc4 (diff)
Fixes #2658 -- Modified SQLite cursor close() method for in-memory databases, making the lifespan of an in-memory database equal to the life of the process, rather than the life of the cursor. Thanks, Ned Batchelder.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends/sqlite3')
-rw-r--r--django/db/backends/sqlite3/base.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 68452e1363..a3e8f0d584 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -62,7 +62,10 @@ class DatabaseWrapper(local):
self.connection.rollback()
def close(self):
- if self.connection is not None:
+ from django.conf import settings
+ # If database is in memory, closing the connection destroys the database.
+ # To prevent accidental data loss, ignore close requests on an in-memory db.
+ if self.connection is not None and settings.DATABASE_NAME != ":memory:":
self.connection.close()
self.connection = None