Documentation ¶
Overview ¶
Package driver implements an SQL driver for an add database.
Index ¶
- Constants
- type Conn
- func (c *Conn) Begin() (driver.Tx, error)
- func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
- func (c *Conn) Close() error
- func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
- func (c *Conn) Ping(ctx context.Context) error
- func (c *Conn) Prepare(query string) (driver.Stmt, error)
- func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
- type Connector
- type Driver
- type Error
- type Stmt
- func (s *Stmt) Close() error
- func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)
- func (s *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error)
- func (s *Stmt) NumInput() int
- func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)
- func (s *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error)
Constants ¶
const (
ErrConnectionClosed = Error("connection is closed")
)
Constant errors
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct { }
Conn represents a connection to the database. It can be used to prepare and execute statements.
func (*Conn) Close ¶
Close closes this connection. If a connection is closed, it cannot be used as idle connection in the connection pool and a new connection needs to be established.
func (*Conn) ExecContext ¶
func (c *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error)
ExecContext executes the given query with the given arguments under the given context and returns an exec result. The statement must contain placeholders, one for each element of the given arguments.
func (*Conn) Ping ¶
Ping pings the database, failing if the connection is closed or the database failed.
func (*Conn) Prepare ¶
Prepare prepares a statement. The returned Stmt is an SQL prepared statement, that has placeholders for parameters that need to be set. Do NOT set parameters directly when creating the statement with this method.
stmt, err := conn.Prepare(`INSERT INTO users VALUES ("jdoe")`) // WRONG stmt, err := conn.Prepare(`INSERT INTO users VALUES (?)`) // CORRECT result, err := stmt.Exec("jdoe")
func (*Conn) QueryContext ¶
func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)
QueryContext executes the given query with the given arguments under the given context and returns a query result. The query must contain placeholders, one for each element of the given arguments.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector implements a component that is able to open a connection to the database that is remembered by the connector. This connection can then be used to prepare and execute statements.
type Driver ¶
type Driver struct { }
Driver is the database driver that can communicate with an add database. It will be registered with the name "add".
type Stmt ¶
type Stmt struct { }
Stmt is a prepared statement that can be executed. It does not remember values that were passed in.
func (*Stmt) ExecContext ¶
ExecContext executes this statement with the given arguments as arguments, with respect to the given context. This should be used for update statements only (alter, update, drop, delete etc.).
func (*Stmt) NumInput ¶
NumInput returns the amount of argument placeholders that the statement has.
func (*Stmt) QueryContext ¶
QueryContext executes this statement with the given arguments as arguments, with respect to the given context. This should be used for query statements only (select etc.).