interface.go 582 B

123456789101112131415161718192021222324
  1. package gorm
  2. import (
  3. "context"
  4. "database/sql"
  5. )
  6. // SQLCommon is the minimal database connection functionality gorm requires. Implemented by *sql.DB.
  7. type SQLCommon interface {
  8. Exec(query string, args ...interface{}) (sql.Result, error)
  9. Prepare(query string) (*sql.Stmt, error)
  10. Query(query string, args ...interface{}) (*sql.Rows, error)
  11. QueryRow(query string, args ...interface{}) *sql.Row
  12. }
  13. type sqlDb interface {
  14. Begin() (*sql.Tx, error)
  15. BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
  16. }
  17. type sqlTx interface {
  18. Commit() error
  19. Rollback() error
  20. }