drivers

package
v0.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available added in v0.4.0

func Available() map[string]Driver

Available returns the available drivers.

func CanChangePassword added in v0.5.0

func CanChangePassword(u *dburl.URL) error

CanChangePassword returns whether or not the specified driver's URL supports changing passwords.

func ChangePassword added in v0.5.0

func ChangePassword(u *dburl.URL, db DB, user, new, old string) (string, error)

ChangePassword initiates a user password change for the specified URL's driver. If user is not supplied, then the current user will be retrieved from User.

func Columns added in v0.4.0

func Columns(u *dburl.URL, rows *sql.Rows) ([]string, error)

Columns returns the columns for SQL result for the specified URL's driver.

func ConfigStmt added in v0.6.0

func ConfigStmt(u *dburl.URL, buf *stmt.Stmt)

ConfigStmt sets the stmt.Stmt config for the specified driver.

func ConvertBytes added in v0.4.0

func ConvertBytes(u *dburl.URL, tfmt string, buf []byte) string

ConvertBytes converts a raw byte slice for a specified URL's driver.

func ForceParams added in v0.6.0

func ForceParams(u *dburl.URL)

ForceParams forces parameters on the supplied DSN for the registered driver.

func ForceQueryParameters added in v0.6.0

func ForceQueryParameters(params []string) func(*dburl.URL)

ForceQueryParameters is a utility func that wraps forcing params of name, value pairs.

func IsPasswordErr added in v0.4.0

func IsPasswordErr(u *dburl.URL, err error) bool

IsPasswordErr returns true if the specified err is a password error for the specified URL's driver.

func Lexer added in v0.6.0

func Lexer(u *dburl.URL) chroma.Lexer

Lexer returns the syntax lexer for a specified URL's driver.

func NextResultSet added in v0.4.0

func NextResultSet(q *sql.Rows) bool

NextResultSet is a wrapper around the go1.8 introduced sql.Rows.NextResultSet call.

func Open added in v0.4.0

func Open(u *dburl.URL) (*sql.DB, error)

Open opens a sql.DB connection for the registered driver.

func Ping added in v0.4.0

func Ping(u *dburl.URL, db *sql.DB) error

Ping pings the database for a specified URL's driver.

func Process added in v0.4.0

func Process(u *dburl.URL, prefix, sqlstr string) (string, string, bool, error)

Process processes the supplied SQL query for the specified URL's driver.

func QueryExecType added in v0.4.0

func QueryExecType(prefix, sqlstr string) (string, bool)

QueryExecType is the default way to determine the "EXEC" prefix for a SQL query and whether or not it should be Exec'd or Query'd.

func Register added in v0.4.0

func Register(name string, d Driver, aliases ...string)

Register registers driver d with name and associated aliases.

func Registered added in v0.4.0

func Registered(name string) bool

Registered returns whether or not a specific driver has been registered.

func RequirePreviousPassword added in v0.5.0

func RequirePreviousPassword(u *dburl.URL) bool

RequirePreviousPassword returns true if the specified URL's driver requires a previous password when changing a user's password.

func RowsAffected added in v0.4.0

func RowsAffected(u *dburl.URL, res sql.Result) (int64, error)

RowsAffected returns the rows affected for the SQL result for a specified URL's driver.

func User added in v0.5.0

func User(u *dburl.URL, db DB) (string, error)

User returns the current database user for the specified URL's driver.

func Version added in v0.4.0

func Version(u *dburl.URL, db DB) (string, error)

Version returns information about the database connection for the specified URL's driver.

func WrapErr added in v0.4.0

func WrapErr(name string, err error) error

WrapErr wraps an error using the specified driver when err is not nil.

Types

type DB added in v0.5.0

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

DB is the common interface for database operations, compatible with database/sql.DB and database/sql.Tx.

type Driver added in v0.4.0

type Driver struct {
	// N is a name to override the driver name with.
	N string

	// AD will be passed to query buffers to enable dollar ($$) style strings.
	AD bool

	// AMC will be passed to query buffers to enable multiline (/**/) style
	// comments.
	AMC bool

	// ACC will be passed to query buffers to enable C (//) style comments.
	ACC bool

	// AHC will be passed to query buffers to enable hash (#) style comments.
	AHC bool

	// ReqPP will be used by RequirePreviousPassword.
	ReqPP bool

	// Syn is the name of the syntax lexer to use.
	Syn string

	// FP will be used to force parameters if defined.
	FP func(*dburl.URL)

	// O will be used by Open if defined.
	O func(*dburl.URL) (func(string, string) (*sql.DB, error), error)

	// V will be used by Version if defined.
	V func(DB) (string, error)

	// U will be used by User if defined.
	U func(DB) (string, error)

	// ChPw will be used by ChangePassword if defined.
	ChPw func(DB, string, string, string) error

	// PwErr will be used by IsPasswordErr if defined.
	PwErr func(error) bool

	// P will be used by Process if defined.
	P func(string, string) (string, string, bool, error)

	// Cols will be used to retrieve the columns for the rows if defined.
	Cols func(*sql.Rows) ([]string, error)

	// Cb will be used by ConvertBytes to convert a raw []byte slice to a
	// string if defined.
	Cb func(string, []byte) string

	// E will be used by Error.Error if defined.
	E func(error) (string, string)

	// A will be used by RowsAffected if defined.
	A func(sql.Result) (int64, error)
}

Driver holds funcs for a driver.

type Error added in v0.4.0

type Error struct {
	Driver string
	Err    error
}

Error is a wrapper to standardize errors.

func (*Error) Error added in v0.4.0

func (e *Error) Error() string

Error satisfies the error interface, returning simple information about the wrapped error in standardized way.

Jump to

Keyboard shortcuts

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