Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How to get sql.Tx with orignal database/sql ? #626

Closed
BeanWei opened this issue Mar 16, 2021 · 1 comment
Closed

[Question]: How to get sql.Tx with orignal database/sql ? #626

BeanWei opened this issue Mar 16, 2021 · 1 comment

Comments

@BeanWei
Copy link

BeanWei commented Mar 16, 2021

I write a plugin for my project, but I don't want to rely on upper/db.

I need get the tx *sql.Tx from upper db db.Session. How can i do?

@BeanWei BeanWei closed this as completed Mar 16, 2021
@gmhafiz
Copy link

gmhafiz commented Nov 19, 2021

For reference, code is in

db/session.go

Line 70 in cb7617e

// internalSQLDriver := sess.Driver().(*sql.DB)

To use

internalSQLDriver := sess.Driver().(*sql.DB)
tx, err := internalSQLDriver.BeginTx(ctx, &sql.TxOptions{
    Isolation: ...
    ReadOnly:  ...,
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants