Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#6710 closed (fixed)

DATABASE_OPTIONS ignored for postgresql_psycopg2

Reported by: Robert Coup Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: postgres
Cc: benjamin.slavin@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Psycopg2 only looks in the kwargs passed to psycopg2.connect() if there is no dsn string. In django this means everything set in settings.DATABASE_OPTIONS is happily ignored (eg. sslmode) because _cursor() builds a dsn string.

The attached patch makes all the db params into a dictionary passed via kwargs instead.

Attachments (1)

psycopg2_connection_params.diff (1.7 KB) - added by Robert Coup 9 years ago.

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Robert Coup

comment:1 Changed 9 years ago by Robert Coup

Link to the relevant code in psycopg2.

Testing for sslmode is actually quite nasty:

  1. in postgresql.conf set:
    • log_min_messages=debug5
    • log_min_error_statement=debug5
  2. reload PG
  3. set DATABASE_OPTIONS['sslmode'] to one of the sslmode settings.
  4. look in your PG log for the absence/presence of a line like:
    2008-03-02 15:23:49 NZDT 850 DEBUG:  SSL connection from "(anonymous)"
    

comment:2 Changed 8 years ago by Marc Fargas

Triage Stage: UnreviewedAccepted

help(psycopg2.connect) says it all.

comment:3 Changed 8 years ago by Joey Wilhelm

Are there any plans to integrate this patch? I prefer to use direct releases/checkouts whenever possible, without having to apply patches and this is pretty much a blocker bug for me at the moment.

comment:4 Changed 8 years ago by Ben Slavin

Cc: benjamin.slavin@… added

comment:5 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [9981]) Fixed #6710 -- Made DATABASE_OPTIONS work with postgresql_psycopg2 backend.

Thanks to rcoup for the patch.

comment:6 Changed 8 years ago by Malcolm Tredinnick

(In [9982]) [1.0.X] Fixed #6710 -- Made DATABASE_OPTIONS work with postgresql_psycopg2 backend.

Thanks to rcoup for the patch.

Backport of r9981 from trunk.

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