ipld-eth-statedb/sql/sqlx.go

31 lines
730 B
Go
Raw Permalink Normal View History

package sql
import (
"context"
"github.com/jmoiron/sqlx"
)
var _ Driver = &SQLXDriver{}
// SQLXDriver driver, implements Driver
type SQLXDriver struct {
ctx context.Context
db *sqlx.DB
}
// NewSQLXDriverFromPool returns a new sqlx driver for Postgres
2023-04-11 09:42:11 +00:00
func NewSQLXDriverFromPool(ctx context.Context, db *sqlx.DB) *SQLXDriver {
return &SQLXDriver{ctx: ctx, db: db}
}
// QueryRow satisfies sql.Database
func (driver *SQLXDriver) QueryRow(_ context.Context, sql string, args ...interface{}) ScannableRow {
return driver.db.QueryRowx(sql, args...)
}
// Exec satisfies sql.Database
func (driver *SQLXDriver) Exec(_ context.Context, sql string, args ...interface{}) (Result, error) {
return driver.db.Exec(sql, args...)
}