Django

Code

Ticket #6710 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

DATABASE_OPTIONS ignored for postgresql_psycopg2

Reported by: rcoup Assigned to: nobody
Milestone: Component: Database layer (models, ORM)
Version: SVN Keywords: postgres
Cc: benjamin.slavin@gmail.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

psycopg2_connection_params.diff (1.7 kB) - added by rcoup on 03/04/08 00:29:10.

Change History

03/04/08 00:29:10 changed by rcoup

  • attachment psycopg2_connection_params.diff added.

03/04/08 00:55:30 changed by rcoup

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

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)"
    

06/14/08 06:17:00 changed by telenieko

  • stage changed from Unreviewed to Accepted.

help(psycopg2.connect) says it all.

10/14/08 14:45:25 changed 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.

12/30/08 08:45:58 changed by __hawkeye__

  • cc set to benjamin.slavin@gmail.com.

03/05/09 20:36:56 changed by mtredinnick

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

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

Thanks to rcoup for the patch.

03/05/09 20:38:39 changed 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.


Add/Change #6710 (DATABASE_OPTIONS ignored for postgresql_psycopg2)




Change Properties
Action