Opened 10 years ago

Last modified 7 weeks ago

#14845 new New feature

Document connection-creation process

Reported by: Christophe Pettus Owned by: nobody
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


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 (12)

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

Triage Stage: UnreviewedAccepted

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

comment:2 Changed 10 years ago by Thomas Güttler

Cc: hv@… added

comment:3 Changed 10 years ago by James Addison

Severity: Normal
Type: New feature

comment:4 Changed 9 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 9 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 8 years ago by Anssi Kääriäinen

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 Changed 8 years ago by Aymeric Augustin

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 Changed 8 years ago by Anssi Kääriäinen

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 Changed 8 years ago by Tim Graham

Easy pickings: unset
Version: 1.3-alphamaster

comment:10 Changed 7 years ago by Tim Graham

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

comment:11 Changed 7 weeks ago by Carlton Gibson

#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 Changed 7 weeks ago by GwynBleidD

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