Opened 14 years ago
Last modified 16 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 , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
Cc: | added |
---|
comment:3 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:6 by , 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 , 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 , 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 , 11 years ago
Easy pickings: | unset |
---|---|
Version: | 1.3-alpha → master |
comment:10 by , 10 years ago
Summary: | Refactor backend connection-creation process → Document connection-creation process |
---|
comment:11 by , 4 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 , 4 years ago
Cc: | added |
---|
comment:13 by , 3 years ago
Whoever takes this should remember to document close_old_connections
(https://code.djangoproject.com/ticket/32589).
comment:14 by , 16 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Absent of any code, it seems like a reasonable proposal.