Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#6710 closed (fixed)

DATABASE_OPTIONS ignored for postgresql_psycopg2

Reported by: rcoup 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 rcoup 7 years ago.

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by rcoup

comment:1 Changed 7 years ago by rcoup

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 7 years ago by telenieko

  • Triage Stage changed from Unreviewed to Accepted

help(psycopg2.connect) says it all.

comment:3 Changed 7 years ago by Tarken

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 6 years ago by __hawkeye__

  • Cc benjamin.slavin@… added

comment:5 Changed 6 years ago by mtredinnick

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

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

Thanks to rcoup for the patch.

comment:6 Changed 6 years ago by mtredinnick

(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