Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored October 14, 2005
3  django/conf/global_settings.py
@@ -49,7 +49,8 @@
49 49
 DATABASE_NAME = ''
50 50
 DATABASE_USER = ''
51 51
 DATABASE_PASSWORD = ''
52  
-DATABASE_HOST = ''             # Set to empty string for localhost
  52
+DATABASE_HOST = ''             # Set to empty string for localhost.
  53
+DATABASE_PORT = ''             # Set to empty string for default.
53 54
 
54 55
 # Host for sending e-mail.
55 56
 EMAIL_HOST = 'localhost'
1  django/conf/project_template/settings/main.py
@@ -15,6 +15,7 @@
15 15
 DATABASE_USER = ''             # Not used with sqlite3.
16 16
 DATABASE_PASSWORD = ''         # Not used with sqlite3.
17 17
 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
  18
+DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
18 19
 
19 20
 SITE_ID = 1
20 21
 
14  django/core/db/backends/mysql.py
@@ -53,10 +53,18 @@ def __init__(self):
53 53
         self.queries = []
54 54
 
55 55
     def cursor(self):
56  
-        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG
  56
+        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG
57 57
         if self.connection is None:
58  
-            self.connection = Database.connect(user=DATABASE_USER, db=DATABASE_NAME,
59  
-                passwd=DATABASE_PASSWORD, host=DATABASE_HOST, conv=django_conversions)
  58
+            kwargs = {
  59
+                'user': DATABASE_USER,
  60
+                'db': DATABASE_NAME,
  61
+                'passwd': DATABASE_PASSWORD,
  62
+                'host': DATABASE_HOST,
  63
+                'conv': django_conversions,
  64
+            }
  65
+            if DATABASE_PORT:
  66
+                kwargs['port'] = DATABASE_PORT
  67
+            self.connection = Database.connect(**kwargs)
60 68
         if DEBUG:
61 69
             return base.CursorDebugWrapper(MysqlDebugWrapper(self.connection.cursor()), self)
62 70
         return self.connection.cursor()
4  django/core/db/backends/postgresql.py
@@ -15,7 +15,7 @@ def __init__(self):
15 15
         self.queries = []
16 16
 
17 17
     def cursor(self):
18  
-        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE
  18
+        from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE
19 19
         if self.connection is None:
20 20
             if DATABASE_NAME == '':
21 21
                 from django.core.exceptions import ImproperlyConfigured
@@ -27,6 +27,8 @@ def cursor(self):
27 27
                 conn_string += " password=%s" % DATABASE_PASSWORD
28 28
             if DATABASE_HOST:
29 29
                 conn_string += " host=%s" % DATABASE_HOST
  30
+            if DATABASE_PORT:
  31
+                conn_string += " port=%s" % DATABASE_PORT
30 32
             self.connection = Database.connect(conn_string)
31 33
             self.connection.set_isolation_level(1) # make transactions transparent to all cursors
32 34
         cursor = self.connection.cursor()

0 notes on commit f2088d4

Please sign in to comment.
Something went wrong with that request. Please try again.