Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #618 -- Added DATABASE_PORT setting. Thanks, Esaj

git-svn-id: http://code.djangoproject.com/svn/django/trunk@858 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f2088d456c4ca394f59d179e990c6e611e92ff5f 1 parent d5bbe39
Adrian Holovaty adrianholovaty authored
3  django/conf/global_settings.py
View
@@ -49,7 +49,8 @@
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'
1  django/conf/project_template/settings/main.py
View
@@ -15,6 +15,7 @@
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
14 django/core/db/backends/mysql.py
View
@@ -53,10 +53,18 @@ def __init__(self):
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()
4 django/core/db/backends/postgresql.py
View
@@ -15,7 +15,7 @@ def __init__(self):
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 @@ def cursor(self):
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()
Please sign in to comment.
Something went wrong with that request. Please try again.