[go] refactoring
This commit is contained in:
parent
44477a6dbd
commit
c069de3955
4 changed files with 25 additions and 10 deletions
19
golang/pkg/database/db.go
Normal file
19
golang/pkg/database/db.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DB struct {
|
||||
ctx context.Context
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func (db *DB) Exec(query string, args ...any) (sql.Result, error) {
|
||||
return db.db.ExecContext(db.ctx, query, args...)
|
||||
}
|
||||
|
||||
func (db *DB) QueryRow(query string, args ...any) *sql.Row {
|
||||
return db.db.QueryRowContext(db.ctx, query, args...)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue