dbinterface

package
v0.0.0-...-b631e0d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 4 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 creates tables, and later drops them and issues some queries

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 Transaction

type Transaction interface {
	DB
	Commit() error
	Rollback() error
	Stmt(stmt *sql.Stmt) *sql.Stmt
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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