Opened 19 years ago

Closed 19 years ago

Last modified 18 years ago

#491 closed defect (fixed)

Patch to allow non-user PostgreSQL connections.

Reported by: jafo@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

pgsql-nouser.patch (1.2 KB ) - added by jafo@… 19 years ago.
pgsql-nouser.patch

Download all attachments as: .zip

Change History (2)

by jafo@…, 19 years ago

Attachment: pgsql-nouser.patch added

pgsql-nouser.patch

comment:1 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

Fixed in [647].

Note: See TracTickets for help on using tickets.
Back to Top