dbinterface

package
v0.0.0-...-891ad17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(db DB) error

Create makes a table called example and populates it

func Exec

func Exec(db DB) error

Exec replaces the Exec from the previous recipe

func Query

func Query(db DB) error

Query grabs a new connection and issues some queries printing the results

Types

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Prepare(query string) (*sql.Stmt, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

DB is an interface that is satisfied by an sql.DB or an sql.Transaction

type MockDB

type MockDB struct {
	// contains filtered or unexported fields
}

Mock of DB interface

func NewMockDB

func NewMockDB(ctrl *gomock.Controller) *MockDB

func (*MockDB) EXPECT

func (_m *MockDB) EXPECT() *_MockDBRecorder

func (*MockDB) Exec

func (_m *MockDB) Exec(_param0 string, _param1 ...interface{}) (sql.Result, error)

func (*MockDB) Prepare

func (_m *MockDB) Prepare(_param0 string) (*sql.Stmt, error)

func (*MockDB) Query

func (_m *MockDB) Query(_param0 string, _param1 ...interface{}) (*sql.Rows, error)

func (*MockDB) QueryRow

func (_m *MockDB) QueryRow(_param0 string, _param1 ...interface{}) *sql.Row

type MockTransaction

type MockTransaction struct {
	// contains filtered or unexported fields
}

Mock of Transaction interface

func NewMockTransaction

func NewMockTransaction(ctrl *gomock.Controller) *MockTransaction

func (*MockTransaction) Commit

func (_m *MockTransaction) Commit() error

func (*MockTransaction) EXPECT

func (_m *MockTransaction) EXPECT() *_MockTransactionRecorder

func (*MockTransaction) Exec

func (_m *MockTransaction) Exec(_param0 string, _param1 ...interface{}) (sql.Result, error)

func (*MockTransaction) Prepare

func (_m *MockTransaction) Prepare(_param0 string) (*sql.Stmt, error)

func (*MockTransaction) Query

func (_m *MockTransaction) Query(_param0 string, _param1 ...interface{}) (*sql.Rows, error)

func (*MockTransaction) QueryRow

func (_m *MockTransaction) QueryRow(_param0 string, _param1 ...interface{}) *sql.Row

func (*MockTransaction) Rollback

func (_m *MockTransaction) Rollback() error

func (*MockTransaction) Stmt

func (_m *MockTransaction) Stmt(_param0 *sql.Stmt) *sql.Stmt

type Transaction

type Transaction interface {
	DB
	Commit() error
	Rollback() error
}

Transaction can do anything a Query can do plus Commit, Rollback, or Stmt

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL