Django

Code

Ticket #491 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

Patch to allow non-user PostgreSQL connections.

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

Description

I'm just using the user the application is running as for the database connection, so I use "dbname=whatever" as the psycopg connection string. The PostgreSQL backend requires "user=". The following patch fixes this.

Index: core/db/backends/postgresql.py =================================================================== --- core/db/backends/postgresql.py (revision 632) +++ core/db/backends/postgresql.py (working copy) @@ -17,10 +17,12 @@

def cursor(self):

from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE

_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE

if self.connection is None:

- if DATABASE_NAME == or DATABASE_USER == : + if DATABASE_NAME == :

from django.core.exceptions import ImproperlyConfigured?

- raise ImproperlyConfigured?, "You need to specify both DATABASE_ NAME and DATABASE_USER in your Django settings file." - conn_string = "user=%s dbname=%s" % (DATABASE_USER, DATABASE_NAME) + raise ImproperlyConfigured?, "You need to specify the DATABASE_N AME in your Django settings file." + conn_string = "dbname=%s" % DATABASE_NAME + if DATABASE_USER: + conn_string = "user=%s %s" % ( DATABASE_USER, conn_string )

if DATABASE_PASSWORD:

conn_string += " password=%s" % DATABASE_PASSWORD

if DATABASE_HOST:

Attachments

pgsql-nouser.patch (1.2 kB) - added by jafo@tummy.com on 09/12/05 01:27:27.
pgsql-nouser.patch

Change History

09/12/05 01:27:27 changed by jafo@tummy.com

  • attachment pgsql-nouser.patch added.

pgsql-nouser.patch

09/18/05 20:23:13 changed by adrian

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

Fixed in [647].


Add/Change #491 (Patch to allow non-user PostgreSQL connections.)




Change Properties
Action