# README
Golang fast SQL toolbox
Named parameters, Transactions with Context
- Faster named parameters, no reflection!
- Simpler consistency - Transactions always commit or rollback!
- SQL with Context, you should catch problems from the outside.
- Improving Developer experience enforcing Good practices.
Named parameters
skill := "go"
FetchRows(db, ctx, "SELECT me FROM devs WHERE skills = :skill", Named{"skill": skill})
fixed: https://github.com/go-sql-driver/mysql/issues/561
Single or Multiple Transaction
Open a connection and Ping it || reuse your existing *sql.DB
// main.go
c := toolbox.ConfigFromEnvs("TEST")
db, err := toolbox.Open(c, ctx)
if err != nil {
// do smtg clever
}
//db.SetMaxLifetimeMins(15) optional set it
Create a context || reuse the existing (from the http-framework maybe)
// in repo.go
// ctx = context.Background() or reuse the ctx from the request/response framework
tx, err := toolbox.TxCreate(db, ctx)
if toolbox.IsErrorRollback(err, tx) {
// do smtg clever, tx is already rollbacked
}
// start using the transaction
incrementalOId, err := toolbox.TxPush(tx, ctx, "insert into `order` (name) values (:name)", toolbox.Named{"name": "value to insert"})
if toolbox.IsErrorRollback(err, tx) {
// do smtg clever is already rollbacked
}
incrementalIId, err := toolbox.TxPush(tx, ctx, "insert into `item` (order_id) values (:order_id)", toolbox.Named{"order_id": incrementalOId})
if toolbox.IsErrorRollback(err, tx) {
// do smtg clever is already rollbacked
}
if tx.Commit() != nil {
// do smtg clever
}
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
FetchRowsPrepared Is like TxCreate+TxFetchRow Remember to run Tx.Commit() or Tx.Rollback().
FetchRowsPrepared Is like TxCreate+TxFetchRow Remember to run Tx.Commit() or Tx.Rollback().
IsErrorRollback should replace the err!=nil check on Error it Rollback the tx.
No description provided by the author
No description provided by the author
PushPrepared Is like TxCreate+TxPush+tx.Commit in once.
PushPrepared Is like TxCreate+TxPush+tx.Commit in once.
No description provided by the author
Create a Transaction.
Query Execution on Transaction.
Query Execution on Transaction by Prepared args (?,?).
Query Execution on Transaction.
Query Execution on Transaction with Prepared args (?,?).
# Constants
No description provided by the author
# Interfaces
No description provided by the author
# Type aliases
No description provided by the author