Ticket #2866: ticket2866.diff
File ticket2866.diff, 8.4 KB (added by , 18 years ago) |
---|
-
django/conf/global_settings.py
100 100 DATABASE_PASSWORD = '' # Not used with sqlite3. 101 101 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. 102 102 DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. 103 DATABASE_OPTIONS = {} # Set to empy dictionary for default. 103 104 104 105 # Host for sending e-mail. 105 106 EMAIL_HOST = 'localhost' -
django/db/__init__.py
6 6 7 7 if not settings.DATABASE_ENGINE: 8 8 settings.DATABASE_ENGINE = 'dummy' 9 if not settings.DATABASE_OPTIONS: 10 settings.DATABASE_OPTIONS = {} 9 11 10 12 try: 11 13 backend = __import__('django.db.backends.%s.base' % settings.DATABASE_ENGINE, '', '', ['']) … … 27 29 get_creation_module = lambda: __import__('django.db.backends.%s.creation' % settings.DATABASE_ENGINE, '', '', ['']) 28 30 runshell = lambda: __import__('django.db.backends.%s.client' % settings.DATABASE_ENGINE, '', '', ['']).runshell() 29 31 30 connection = backend.DatabaseWrapper( )32 connection = backend.DatabaseWrapper(**settings.DATABASE_OPTIONS) 31 33 DatabaseError = backend.DatabaseError 32 34 33 35 # Register an event that closes the database connection -
django/db/backends/ado_mssql/base.py
55 55 from django.utils._threading_local import local 56 56 57 57 class DatabaseWrapper(local): 58 def __init__(self ):58 def __init__(self, **kwargs): 59 59 self.connection = None 60 60 self.queries = [] 61 61 -
django/db/backends/postgresql/base.py
21 21 from django.utils._threading_local import local 22 22 23 23 class DatabaseWrapper(local): 24 def __init__(self ):24 def __init__(self, **kwargs): 25 25 self.connection = None 26 26 self.queries = [] 27 self.options = kwargs 27 28 28 29 def cursor(self): 29 30 from django.conf import settings … … 40 41 conn_string += " host=%s" % settings.DATABASE_HOST 41 42 if settings.DATABASE_PORT: 42 43 conn_string += " port=%s" % settings.DATABASE_PORT 43 self.connection = Database.connect(conn_string )44 self.connection = Database.connect(conn_string, **self.options) 44 45 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 45 46 cursor = self.connection.cursor() 46 47 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) -
django/db/backends/sqlite3/base.py
42 42 from django.utils._threading_local import local 43 43 44 44 class DatabaseWrapper(local): 45 def __init__(self ):45 def __init__(self, **kwargs): 46 46 self.connection = None 47 47 self.queries = [] 48 self.options = kwargs 48 49 49 50 def cursor(self): 50 51 from django.conf import settings 51 52 if self.connection is None: 52 self.connection = Database.connect(settings.DATABASE_NAME, 53 detect_types=Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES) 54 53 kwargs = { 54 'database': settings.DATABASE_NAME, 55 'detect_types': Database.PARSE_DECLTYPES | Database.PARSE_COLNAMES, 56 } 57 kwargs.update(self.options) 58 self.connection = Database.connect(**kwargs) 55 59 # Register extract and date_trunc functions. 56 60 self.connection.create_function("django_extract", 2, _sqlite_extract) 57 61 self.connection.create_function("django_date_trunc", 2, _sqlite_date_trunc) -
django/db/backends/mysql/base.py
65 65 from django.utils._threading_local import local 66 66 67 67 class DatabaseWrapper(local): 68 def __init__(self ):68 def __init__(self, **kwargs): 69 69 self.connection = None 70 70 self.queries = [] 71 71 self.server_version = None 72 self.options = kwargs 72 73 73 74 def _valid_connection(self): 74 75 if self.connection is not None: … … 95 96 kwargs['host'] = settings.DATABASE_HOST 96 97 if settings.DATABASE_PORT: 97 98 kwargs['port'] = int(settings.DATABASE_PORT) 99 kwargs.update(self.options) 98 100 self.connection = Database.connect(**kwargs) 99 101 cursor = self.connection.cursor() 100 102 if self.connection.get_server_info() >= '4.1': -
django/db/backends/oracle/base.py
21 21 from django.utils._threading_local import local 22 22 23 23 class DatabaseWrapper(local): 24 def __init__(self ):24 def __init__(self, **kwargs): 25 25 self.connection = None 26 26 self.queries = [] 27 self.options = kwargs 27 28 28 29 def _valid_connection(self): 29 30 return self.connection is not None … … 35 36 settings.DATABASE_HOST = 'localhost' 36 37 if len(settings.DATABASE_PORT.strip()) != 0: 37 38 dsn = Database.makedsn(settings.DATABASE_HOST, int(settings.DATABASE_PORT), settings.DATABASE_NAME) 38 self.connection = Database.connect(settings.DATABASE_USER, settings.DATABASE_PASSWORD, dsn )39 self.connection = Database.connect(settings.DATABASE_USER, settings.DATABASE_PASSWORD, dsn, **self.options) 39 40 else: 40 41 conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) 41 self.connection = Database.connect(conn_string )42 self.connection = Database.connect(conn_string, **self.options) 42 43 return FormatStylePlaceholderCursor(self.connection) 43 44 44 45 def _commit(self): -
django/db/backends/postgresql_psycopg2/base.py
21 21 from django.utils._threading_local import local 22 22 23 23 class DatabaseWrapper(local): 24 def __init__(self ):24 def __init__(self, **kwargs): 25 25 self.connection = None 26 26 self.queries = [] 27 self.options = kwargs 27 28 28 29 def cursor(self): 29 30 from django.conf import settings … … 40 41 conn_string += " host=%s" % settings.DATABASE_HOST 41 42 if settings.DATABASE_PORT: 42 43 conn_string += " port=%s" % settings.DATABASE_PORT 43 self.connection = Database.connect(conn_string )44 self.connection = Database.connect(conn_string, **self.options) 44 45 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 45 46 cursor = self.connection.cursor() 46 47 cursor.tzinfo_factory = None -
django/db/backends/dummy/base.py
20 20 _commit = complain 21 21 _rollback = complain 22 22 23 def __init__(self, **kwargs): 24 pass 25 23 26 def close(self): 24 27 pass # close() 25 28 -
docs/settings.txt
265 265 The name of the database to use. For SQLite, it's the full path to the database 266 266 file. 267 267 268 DATABASE_OPTIONS 269 ---------------- 270 271 Default: ``{}`` (Empty dictionary) 272 273 Extra parameters to use when connecting to the database. Consult backend 274 module's document for available keywords. 275 268 276 DATABASE_PASSWORD 269 277 ----------------- 270 278