Opened 6 years ago

Last modified 2 years ago

#14845 new New feature

Document connection-creation process

Reported by: Christophe Pettus Owned by: nobody
Component: Documentation Version: master
Severity: Normal Keywords:
Cc: hv@… 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 (10)

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

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

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

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

Cc: hv@… added

comment:3 Changed 6 years ago by James Addison

Severity: Normal
Type: New feature

comment:4 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:5 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:6 Changed 3 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 3 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 3 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 3 years ago by Tim Graham

Easy pickings: unset
Version: 1.3-alphamaster

comment:10 Changed 2 years ago by Tim Graham

Summary: Refactor backend connection-creation processDocument connection-creation process
Note: See TracTickets for help on using tickets.
Back to Top