Code

Opened 9 years ago

Closed 9 years ago

Last modified 7 years ago

#491 closed defect (fixed)

Patch to allow non-user PostgreSQL connections.

Reported by: jafo@… Owned by: adrian
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: UI/UX:

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@… 9 years ago.
pgsql-nouser.patch

Download all attachments as: .zip

Change History (2)

Changed 9 years ago by jafo@…

pgsql-nouser.patch

comment:1 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [647].

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.