package sqlitex
import "git.sr.ht/~pingoo/stdx/sqlitex"
Index ¶
- type DB
- func Open(file string, options *DBOptions) (db *DB, err error)
- func (db *DB) Close() (err error)
- func (db *DB) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *DB) Get(ctx context.Context, dest any, query string, args ...any) error
- func (db *DB) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (db *DB) Select(ctx context.Context, dest any, query string, args ...any) error
- func (db *DB) Transaction(ctx context.Context, fn func(tx *Tx) error) (err error)
- type DBOptions
- type Queryer
- type Tx
- func (tx *Tx) Commit() error
- func (tx *Tx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (tx *Tx) Get(ctx context.Context, dest any, query string, args ...any) error
- func (tx *Tx) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
- func (tx *Tx) Rollback() error
- func (tx *Tx) Select(ctx context.Context, dest any, query string, args ...any) error
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func Open ¶
func (*DB) Close ¶
func (*DB) Exec ¶
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*DB) Get ¶
Get a single record. Any placeholder parameters are replaced with supplied args. An `ErrNoRows` error is returned if the result set is empty.
func (*DB) Query ¶
Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func (*DB) Select ¶
Select an array of records. Any placeholder parameters are replaced with supplied args.
func (*DB) Transaction ¶
type DBOptions ¶
type DBOptions struct { BusyTimeout int64 }
type Queryer ¶
type Queryer interface { Get(ctx context.Context, dest any, query string, args ...any) error Select(ctx context.Context, dest any, query string, args ...any) error Query(ctx context.Context, query string, args ...any) (*sql.Rows, error) Exec(ctx context.Context, query string, args ...any) (sql.Result, error) }
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Transaction is wrapper of `sqlx.Tx` which implements `Tx`
func (*Tx) Commit ¶
Commit commits the transaction.
func (*Tx) Exec ¶
Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.
func (*Tx) Get ¶
Get a single record. Any placeholder parameters are replaced with supplied args. An `ErrNoRows` error is returned if the result set is empty.
func (*Tx) Query ¶
Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.
func (*Tx) Rollback ¶
Rollback aborts the transaction.
func (*Tx) Select ¶
Select an array of records. Any placeholder parameters are replaced with supplied args.
Source Files ¶
db.go
- Version
- v0.0.0-20240218134121-094174641f6e (latest)
- Published
- Feb 18, 2024
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 4 months ago –
Tools for package owners.