Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Ability to acquire a connection #2846

@ahmadbky

Description

@ahmadbky

Motivation

We can't force a set of SQL queries to be executed on the same database connection, unless by doing a transaction, which is not what I want.

Additionally, this implies that a database connection used for a set of SQL queries may be used concurrently by another process, because DbConn is simply a pool, which acquires a connection on each query.

This is very unfortunate because it makes it impossible to ensure the lock/unlock of tables properly, for example.

It is indeed possible to do it ourselves, but it is very cumbersome and should be part of this library. Plus, we can't replicate the exact implementation of DbConn (e.g. with metrics etc).

Proposed Solutions

Make an additional type for acquired connections (not pools), that could be constructed from a new acquire method on the DbConn type. This new type would implement the traits ConnectionTrait and why not TransactionTrait.

Additional Information

This issue is related to #1457, which was converted into a discussion here: #1503, but nothing was done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions