Fixed #618 -- Added DATABASE_PORT setting. Thanks, Esaj
git-svn-id: http://code.djangoproject.com/svn/django/trunk@858 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d5bbe395c2
commit
f2088d456c
|
@ -49,7 +49,8 @@ DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', or 'sqlite3'.
|
|||
DATABASE_NAME = ''
|
||||
DATABASE_USER = ''
|
||||
DATABASE_PASSWORD = ''
|
||||
DATABASE_HOST = '' # Set to empty string for localhost
|
||||
DATABASE_HOST = '' # Set to empty string for localhost.
|
||||
DATABASE_PORT = '' # Set to empty string for default.
|
||||
|
||||
# Host for sending e-mail.
|
||||
EMAIL_HOST = 'localhost'
|
||||
|
|
|
@ -15,6 +15,7 @@ DATABASE_NAME = '' # Or path to database file if using sqlite3.
|
|||
DATABASE_USER = '' # Not used with sqlite3.
|
||||
DATABASE_PASSWORD = '' # Not used with sqlite3.
|
||||
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
|
||||
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
|
|
|
@ -53,10 +53,18 @@ class DatabaseWrapper:
|
|||
self.queries = []
|
||||
|
||||
def cursor(self):
|
||||
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG
|
||||
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG
|
||||
if self.connection is None:
|
||||
self.connection = Database.connect(user=DATABASE_USER, db=DATABASE_NAME,
|
||||
passwd=DATABASE_PASSWORD, host=DATABASE_HOST, conv=django_conversions)
|
||||
kwargs = {
|
||||
'user': DATABASE_USER,
|
||||
'db': DATABASE_NAME,
|
||||
'passwd': DATABASE_PASSWORD,
|
||||
'host': DATABASE_HOST,
|
||||
'conv': django_conversions,
|
||||
}
|
||||
if DATABASE_PORT:
|
||||
kwargs['port'] = DATABASE_PORT
|
||||
self.connection = Database.connect(**kwargs)
|
||||
if DEBUG:
|
||||
return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self)
|
||||
return self.connection.cursor()
|
||||
|
|
|
@ -15,7 +15,7 @@ class DatabaseWrapper:
|
|||
self.queries = []
|
||||
|
||||
def cursor(self):
|
||||
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE
|
||||
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE
|
||||
if self.connection is None:
|
||||
if DATABASE_NAME == '':
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
@ -27,6 +27,8 @@ class DatabaseWrapper:
|
|||
conn_string += " password=%s" % DATABASE_PASSWORD
|
||||
if DATABASE_HOST:
|
||||
conn_string += " host=%s" % DATABASE_HOST
|
||||
if DATABASE_PORT:
|
||||
conn_string += " port=%s" % DATABASE_PORT
|
||||
self.connection = Database.connect(conn_string)
|
||||
self.connection.set_isolation_level(1) # make transactions transparent to all cursors
|
||||
cursor = self.connection.cursor()
|
||||
|
|
Loading…
Reference in New Issue