Opened 13 years ago

Last modified 9 months ago

#14845 assigned New feature

Document connection-creation process

Reported by: Christophe Pettus Owned by: Pradhvan Bisht
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: hv@…, GwynBleidD Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, the actual database connection is created on-demand when a cursor is requested. This is great for standard use, but there are occasional uses where it would be handy to have the connection open before requesting a cursor (for example, if you are doing a raw SQL query using the cursor(cursor_factory=) syntax.

The proposal here is to move the connection-creation mechanism to a separate public method that both the internal cursor-creation mechanism and a client of the connection object could call.

Change History (14)

comment:1 by Russell Keith-Magee, 13 years ago

Triage Stage: UnreviewedAccepted

Absent of any code, it seems like a reasonable proposal.

comment:2 by Thomas Güttler, 13 years ago

Cc: hv@… added

comment:3 by James Addison, 13 years ago

Severity: Normal
Type: New feature

comment:4 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 by Anssi Kääriäinen, 11 years ago

Component: Database layer (models, ORM)Documentation
Easy pickings: set

There is connection.connect() and connection.ensure_connection() methods. I don't see a reason why these couldn't be documented (that is, they seem stable enough). Documenting these (or one of these) seems like somewhat easy documentation patch.

comment:7 by Aymeric Augustin, 11 years ago

Anssi, we've made lots of changes in the 1.6 release cycle, and I'm not sure this is the end of the story.

The internal APIs for connection establishement still look messy to me. Just obtaining a cursor involves ten methods or so!

comment:8 by Anssi Kääriäinen, 11 years ago

I agree there is more work to do. There is no need to document everything, just ensure_connection() and connect(). Actually, even .connect() isn't necessary for this ticket. Keeping connection.ensure_connection() stable doesn't seem too bad to me.

Alternative is to document that you can do cursor = connection.cursor(); cursor.close() to ensure a connection exists. But calling methods for their side-effects is a bit ugly.

comment:9 by Tim Graham, 11 years ago

Easy pickings: unset
Version: 1.3-alphamaster

comment:10 by Tim Graham, 10 years ago

Summary: Refactor backend connection-creation processDocument connection-creation process

comment:11 by Carlton Gibson, 3 years ago

#32589 was a duplicate ref documenting the need for calling close_old_connections in long-running management commands.

Ostensibly this ticket here is about connection creation, but (a decade later) a general overview of the connection life-cycle would be a nice improvement.

comment:12 by GwynBleidD, 3 years ago

Cc: GwynBleidD added

comment:13 by dcontador, 2 years ago

Whoever takes this should remember to document close_old_connections (https://code.djangoproject.com/ticket/32589).

comment:14 by Pradhvan Bisht , 9 months ago

Owner: changed from nobody to Pradhvan Bisht
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top