sql

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2019 License: MIT Imports: 3 Imported by: 1

README

sql

SQL wrappers for Go

Documentation

Overview

Package sql provides opinionated interfaces around the database/sql implementations. In general, they are they same except: 1) they accepts context.Context parameters without using the *Context suffix. 2) types are interfaces so they can be easily mocked in tests. 3) Scanner represents a row or rows, rather than a column.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Ping(ctx context.Context) error
	Prepare(ctx context.Context, query string) (Stmt, error)
	BeginTx(ctx context.Context, opts *TxOptions) (Tx, error)
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row
	Close() error
	StdConn() *sql.Conn
}

The following are interface wrappers around concrete types in database/sql.

type DB

type DB interface {
	Ping(ctx context.Context) error
	Prepare(ctx context.Context, query string) (Stmt, error)
	BeginTx(ctx context.Context, opts *TxOptions) (Tx, error)
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row
	Driver() driver.Driver
	StdDB() *sql.DB
}

The following are interface wrappers around concrete types in database/sql.

func Open

func Open(driverName, dataSourceName string) (DB, error)

func OpenDB

func OpenDB(c driver.Connector) (DB, error)

type DBStats

type DBStats = sql.DBStats

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type IsolationLevel

type IsolationLevel = sql.IsolationLevel

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NamedArg

type NamedArg = sql.NamedArg

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

func Named

func Named(name string, value interface{}) NamedArg

Named exposes database/sql.Named(string, interface{})

type NullBool

type NullBool = sql.NullBool

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NullFloat64

type NullFloat64 = sql.NullFloat64

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NullInt32

type NullInt32 = sql.NullInt32

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NullInt64

type NullInt64 = sql.NullInt64

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NullString

type NullString = sql.NullString

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type NullTime

type NullTime = sql.NullTime

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type Out

type Out = sql.Out

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type RawBytes

type RawBytes = sql.RawBytes

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type Result

type Result = sql.Result

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type Row

type Row = sql.Row

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type Rows

type Rows = sql.Rows

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

type Scanner

type Scanner interface {
	Scan(...interface{}) error
}

Scanner abstracts sql.Rows and sql.Row. Note: this is DIFFERENT than the sql.Scanner interface.

type Stmt

type Stmt interface {
	Exec(ctx context.Context, args ...interface{}) (Result, error)
	Query(ctx context.Context, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, args ...interface{}) *Row
	Close() error
	StdStmt() *sql.Stmt
}

The following are interface wrappers around concrete types in database/sql.

type Tx

type Tx interface {
	Commit() error
	Rollback() error
	Prepare(ctx context.Context, query string) (Stmt, error)
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row
	StdTx() *sql.Tx
}

The following are interface wrappers around concrete types in database/sql.

type TxOptions

type TxOptions = sql.TxOptions

The following types are simple aliases that are exported to make it easier to consume this package. These aliases allow users to use this package without also importing database/sql, thus causing a package name collision.

Jump to

Keyboard shortcuts

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