Documentation ¶
Index ¶
- Variables
- func BeginTx() error
- func CommitTx() error
- func Connect(url string) error
- func ExecuteStatements(stmts ...Statement) error
- func ExecuteTx() error
- func IsConnected() bool
- func PrepareAndExecute(query string, args ...interface{}) (sql.Result, error)
- func PrepareAndQuery(query string, args ...interface{}) (*sql.Rows, error)
- func Query(stmt Statement) (*sql.Rows, error)
- func QueryRow(stmt Statement, data ...interface{}) error
- func RollbackTx() error
- type Connection
- func (c *Connection) BeginTx() error
- func (c *Connection) CommitTx() error
- func (c *Connection) ExecuteStatements(stmts ...Statement) error
- func (c *Connection) ExecuteTx() error
- func (c *Connection) IsConnected() bool
- func (c *Connection) PrepareAndExecute(query string, args ...interface{}) (sql.Result, error)
- func (c *Connection) PrepareAndQuery(query string, args ...interface{}) (*sql.Rows, error)
- func (c *Connection) Query(stmt Statement) (*sql.Rows, error)
- func (c *Connection) QueryRow(stmt Statement, data ...interface{}) error
- func (c *Connection) RollbackTx() error
- type Statement
Constants ¶
This section is empty.
Variables ¶
var ErrNoRows = errors.New("Query returned no rows")
var ErrNoTxStarted = errors.New("No transactions in progress")
var ErrPriorTxIssue = errors.New("Transaction was rolled back due to issues with underlying transactions")
Functions ¶
func ExecuteStatements ¶
ExecuteStatements allows the user to execute >= 1 statement in a single sql transaction
func ExecuteTx ¶
func ExecuteTx() error
ExecuteTx determines whether a commit or rollback needs to take place by checking whether any of the components which make up the latest transaction produced an error. A commit occurs on no error, otherwise a rollback takes place
func IsConnected ¶
func IsConnected() bool
IsConnected pings the database and returns true if the connection is still active
func PrepareAndExecute ¶
PrepareAndExecute performs the actions of Prepare and Execute a single statement in one step rather than forcing the user to manually Prepare a statement.
func PrepareAndQuery ¶
PrepareAndQuery performs the actions of Prepare and Query a single statement in one step rather than forcing the user to manually Prepare a statement.
func Query ¶
Query allows the user to perform a query where >= 1 rows are expected back It simply returns the rows so that the user may manipulate the data as they please
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func BuildConnection ¶
func BuildConnection(connection string) (*Connection, error)
BuildConnection takes in a connection string and builds a wrapped connection from it
func (*Connection) CommitTx ¶
func (c *Connection) CommitTx() error
CommitTx commits the last in progress transaction
func (*Connection) ExecuteStatements ¶
func (c *Connection) ExecuteStatements(stmts ...Statement) error
ExecuteStatements allows the user to execute >= 1 statement in a single sql transaction
func (*Connection) ExecuteTx ¶
func (c *Connection) ExecuteTx() error
ExecuteTx determines whether a commit or rollback needs to take place by checking whether any of the components which make up the latest transaction produced an error. A commit occurs on no error, otherwise a rollback takes place. The boolean value returned is an indicator of whether the transaction attempted to commit
func (*Connection) IsConnected ¶
func (c *Connection) IsConnected() bool
IsConnected pings the database and returns true if the connection is still active
func (*Connection) PrepareAndExecute ¶
func (c *Connection) PrepareAndExecute(query string, args ...interface{}) (sql.Result, error)
PrepareAndExecute performs the actions of Prepare and Execute a single statement in one step rather than forcing the user to manually Prepare a statement.
func (*Connection) PrepareAndQuery ¶
func (c *Connection) PrepareAndQuery(query string, args ...interface{}) (*sql.Rows, error)
PrepareAndQuery performs the actions of Prepare and Query a single statement in one step rather than forcing the user to manually Prepare a statement.
func (*Connection) Query ¶
func (c *Connection) Query(stmt Statement) (*sql.Rows, error)
Query allows the user to perform a query where >= 1 rows are expected back It simply returns the rows so that the user may manipulate the data as they please
func (*Connection) QueryRow ¶
func (c *Connection) QueryRow(stmt Statement, data ...interface{}) error
QueryRow allows the user to perform an sql query where only one row is expected The results of the query are put into the passed in data interfaces
func (*Connection) RollbackTx ¶
func (c *Connection) RollbackTx() error
RollbackTx rolls back the last in progress transaction
type Statement ¶
type Statement struct { Query string Args []interface{} }
Statement is a struct which represents a prepared statement. Calling Prepare allows the user to not have to construct this manually.