db_api.go 586 B

12345678910111213141516171819
  1. package util
  2. import (
  3. "context"
  4. "database/sql"
  5. )
  6. type DB interface {
  7. Ping() error
  8. Close() error
  9. ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
  10. Exec(query string, args ...any) (sql.Result, error)
  11. QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
  12. Query(query string, args ...any) (*sql.Rows, error)
  13. QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
  14. QueryRow(query string, args ...any) *sql.Row
  15. BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
  16. Begin() (*sql.Tx, error)
  17. }