Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12941 closed (fixed)

multiple database connections cursors

Reported by: atlithorn@… Owned by: nobody
Component: Documentation Version: 1.2-beta
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


I use connection.cursor for making raw sql queries and needed to access one of the alternate databases in my settings.DATABASES
I had a look through the code and realised that I could just do this

from django.db import connections
cursor = connections['logs'].cursor()

instead of what I had been doing earlier (when everything was in the same database)

from django.db import connection
cursor = connection.cursor()

Multiple database support is really well implemented, I think you should mention the above in your docs somewhere to complete the perfect picture.

Attachments (1)

django-multidb-cursor.diff (684 bytes) - added by Alex Gaynor 7 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 7 years ago by Russell Keith-Magee

milestone: 1.2
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 7 years ago by Alex Gaynor

Attachment: django-multidb-cursor.diff added

comment:2 Changed 7 years ago by Alex Gaynor

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:3 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [12709]) Fixed #12941 -- Added documentation for the connections dictionary. Thanks to atlithorn@… for the report, and Alex Gaynor for the original text.

comment:4 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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