sql

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn represents a single database connection.

func (*Conn) BeginTx

func (c *Conn) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx starts a transaction.

func (*Conn) Close

func (c *Conn) Close(ctx context.Context) error

Close returns the connection to the connection pool.

func (*Conn) Exec

func (c *Conn) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows.

func (*Conn) Ping

func (c *Conn) Ping(ctx context.Context) error

Ping verifies the connection to the database is still alive.

func (*Conn) Prepare

func (c *Conn) Prepare(ctx context.Context, query string) (*Stmt, error)

Prepare creates a prepared statement for later queries or executions.

func (*Conn) Query

func (c *Conn) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows.

func (*Conn) QueryRow

func (c *Conn) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB contains the underlying db to be traced.

func Open

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

Open opens a database.

func OpenDB

func OpenDB(c driver.Connector) *DB

OpenDB opens a database.

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

BeginTx starts a transaction.

func (*DB) Close

func (db *DB) Close(ctx context.Context) error

Close closes the database, releasing any open resources.

func (*DB) Conn

func (db *DB) Conn(ctx context.Context) (*Conn, error)

Conn returns a connection.

func (*DB) Driver

func (db *DB) Driver(ctx context.Context) driver.Driver

Driver returns the database's underlying driver.

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows.

func (*DB) Ping

func (db *DB) Ping(ctx context.Context) error

Ping verifies a connection to the database is still alive, establishing a connection if necessary.

func (*DB) Prepare

func (db *DB) Prepare(ctx context.Context, query string) (*Stmt, error)

Prepare creates a prepared statement for later queries or executions.

func (*DB) Query

func (db *DB) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows.

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row.

func (*DB) SetConnMaxLifetime

func (db *DB) SetConnMaxLifetime(d time.Duration)

SetConnMaxLifetime sets the maximum amount of time a connection may be reused.

func (*DB) SetMaxIdleConns

func (db *DB) SetMaxIdleConns(n int)

SetMaxIdleConns sets the maximum number of connections in the idle connection pool.

func (*DB) SetMaxOpenConns

func (db *DB) SetMaxOpenConns(n int)

SetMaxOpenConns sets the maximum number of open connections to the database.

func (*DB) Stats

func (db *DB) Stats(ctx context.Context) sql.DBStats

Stats returns database statistics.

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

Stmt is a prepared statement.

func (*Stmt) Close

func (s *Stmt) Close(ctx context.Context) error

Close closes the statement.

func (*Stmt) Exec

func (s *Stmt) Exec(ctx context.Context, args ...interface{}) (sql.Result, error)

Exec executes a prepared statement.

func (*Stmt) Query

func (s *Stmt) Query(ctx context.Context, args ...interface{}) (*sql.Rows, error)

Query executes a prepared query statement.

func (*Stmt) QueryRow

func (s *Stmt) QueryRow(ctx context.Context, args ...interface{}) *sql.Row

QueryRow executes a prepared query statement.

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

Tx is an in-progress database transaction.

func (*Tx) Commit

func (tx *Tx) Commit(ctx context.Context) error

Commit commits the transaction.

func (*Tx) Exec

func (tx *Tx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query that doesn't return rows.

func (*Tx) Prepare

func (tx *Tx) Prepare(ctx context.Context, query string) (*Stmt, error)

Prepare creates a prepared statement for use within a transaction.

func (*Tx) Query

func (tx *Tx) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows.

func (*Tx) QueryRow

func (tx *Tx) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that is expected to return at most one row.

func (*Tx) Rollback

func (tx *Tx) Rollback(ctx context.Context) error

Rollback aborts the transaction.

func (*Tx) Stmt

func (tx *Tx) Stmt(ctx context.Context, stmt *Stmt) *Stmt

Stmt returns a transaction-specific prepared statement from an existing statement.

Jump to

Keyboard shortcuts

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