db

package
v0.0.0-...-9a5932e Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2014 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register makes a database driver available by the provided name.

Types

type Conn

type Conn interface {
	Exec(query string, args map[string]interface{}) (Result, error)
	Begin() (Tx, error)
	Close() error
}

Conn is a connection to a database. It should not be used concurrently by multiple goroutines.

func Open

func Open(name, path string) (Conn, error)

Open opens a database specified by its database driver name and a driver-specific data source name, usually consisting of at least a database name and connection information.

type Driver

type Driver interface {
	// Open returns a new connection to the database.
	// The name is a string in a driver-specific format.
	// The returned connection should only be used by one
	// goroutine at a time.
	Open(name string) (Conn, error)
}

Driver is the interface that must be implemented by a database driver.

type Result

type Result interface {
	LastInsertId() (int64, error)
	RowsAffected() (int64, error)
	Columns() []string
	Next() []interface{}
	Err() error
	Close() error
}

Result is an iterator over an executed query's results. It is also used to query for the results of a DML, in which case the iterator functions are not applicable.

type Tx

type Tx interface {
	Commit() error
	Rollback() error
}

Tx is a transaction.

Jump to

Keyboard shortcuts

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