Django

Code

Changeset 3723

Show
Ignore:
Timestamp:
09/05/06 08:32:08 (2 years ago)
Author:
russellm
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/backends/sqlite3/base.py

    r3115 r3723  
    6363 
    6464    def close(self): 
    65         if self.connection is not None: 
     65        from django.conf import settings 
     66        # If database is in memory, closing the connection destroys the database. 
     67        # To prevent accidental data loss, ignore close requests on an in-memory db. 
     68        if self.connection is not None and settings.DATABASE_NAME != ":memory:": 
    6669            self.connection.close() 
    6770            self.connection = None 
  • django/trunk/django/test/utils.py

    r3707 r3723  
    9696    if verbosity >= 1: 
    9797        print "Destroying test database..." 
     98    connection.close() 
     99    TEST_DATABASE_NAME = settings.DATABASE_NAME 
     100    settings.DATABASE_NAME = old_database_name 
     101 
    98102    if settings.DATABASE_ENGINE != "sqlite3": 
    99         connection.close() 
    100         TEST_DATABASE_NAME = settings.DATABASE_NAME 
    101         settings.DATABASE_NAME = old_database_name 
    102103        cursor = connection.cursor() 
    103104        _set_autocommit(connection)