Django

Code

Ticket #618 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

[patch] (reopened) Support for non-standard database port

Reported by: Esaj Assigned to: adrian
Milestone: Component: Database layer (models, ORM)
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

This patch adds support for non-standard database ports, by specifying DATABASE_PORT. Tested with PostgreSQL, but not with MySQL.

Attachments

database_port.patch (3.1 kB) - added by Esaj on 10/12/05 16:28:14.

Change History

10/12/05 16:28:14 changed by Esaj

  • attachment database_port.patch added.

10/13/05 22:23:15 changed by ian@holsman.net

Hi. I tried your patch on mysql, and it was complaining about wanting an integer and not a string for a port. by placing DATABASE_PORT=3306 (which is the default) in global_settings.py it stopped complaining.

10/13/05 22:43:03 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [858]) Fixed #618 -- Added DATABASE_PORT setting. Thanks, Esaj

03/02/06 22:14:24 changed by wmealing@gmail.com

For others who might be seeing this problem.

python manage.py init Error: The database couldn't be initialized. an integer is required

settings.py should have

DATABASE_PORT = 3306 <-- note the integer

not

DATABASE_PORT = '3306' <-- note the quotes.

03/02/06 22:22:10 changed by matt

  • status changed from closed to reopened.
  • resolution deleted.

I think that we should be setting this as a string in the settings file and converting it to an int for MySQL (this doesn't look like an issue for Postgres and it has not been implemented in MSSQL). All of the other database settings are strings and we ship the settings file with DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.

Here are two quick patches to take care of this:

magic-removal:

Index: django/core/db/backends/mysql.py
===================================================================
--- django/core/db/backends/mysql.py	(revision 2475)
+++ django/core/db/backends/mysql.py	(working copy)
@@ -63,7 +63,7 @@
                 'conv': django_conversions,
             }
             if DATABASE_PORT:
-                kwargs['port'] = DATABASE_PORT
+                kwargs['port'] = int(DATABASE_PORT)
             self.connection = Database.connect(**kwargs)
         cursor = self.connection.cursor()
         if self.connection.get_server_info() >= '4.1':

Trunk:

Index: django/db/backends/mysql/base.py
===================================================================
--- django/db/backends/mysql/base.py	(revision 2475)
+++ django/db/backends/mysql/base.py	(working copy)
@@ -62,7 +62,7 @@
                 'conv': django_conversions,
             }
             if settings.DATABASE_PORT:
-                kwargs['port'] = settings.DATABASE_PORT
+                kwargs['port'] = int(settings.DATABASE_PORT)
             self.connection = Database.connect(**kwargs)
         cursor = self.connection.cursor()
         if self.connection.get_server_info() >= '4.1':

03/02/06 22:25:45 changed by matt

  • summary changed from Support for non-standard database port to [patch] (reopened) Support for non-standard database port.

changed summary.

03/02/06 22:45:14 changed by eugene@lazutkin.com

I think Matt mistyped his patches: 1st patch should be applied to the trunk, and 2nd patch is for magic-removal.

03/05/06 19:42:50 changed by matt

Eugene is correct, sorry about that.

04/05/06 10:21:36 changed by jacob

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [2614]) magic-removal: fixed #618 -- the mysql backend now tolerates strings in DATABASE_PORT


Add/Change #618 ([patch] (reopened) Support for non-standard database port)




Change Properties
Action