#618 closed defect (fixed)
[patch] (reopened) Support for non-standard database port
Reported by: | Esaj | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | |
Severity: | normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This patch adds support for non-standard database ports, by specifying DATABASE_PORT. Tested with PostgreSQL, but not with MySQL.
Attachments (1)
Change History (9)
by , 19 years ago
Attachment: | database_port.patch added |
---|
comment:1 by , 19 years ago
comment:2 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 19 years ago
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.
comment:4 by , 19 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
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':
comment:5 by , 19 years ago
Summary: | Support for non-standard database port → [patch] (reopened) Support for non-standard database port |
---|
changed summary.
comment:6 by , 19 years ago
I think Matt mistyped his patches: 1st patch should be applied to the trunk, and 2nd patch is for magic-removal.
comment:8 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
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.