sqlxdb

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 10 Imported by: 0

README

sqldb-sqlx

Actions Status Go Report Card GoDoc

sqldb-sqlx is a sqlx implementation for go-sqldb.

Documentation

Overview

Package sqlxdb contains an sqlx implementation of the sqldb package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*Queryable
	// contains filtered or unexported fields
}

Connection represents the sqlx implementation of the sqldb.Connection interface

func New

func New(driverName, dsn string) (*Connection, error)

New returns a new SQLX connection

func NewUnsafe

func NewUnsafe(driverName, dsn string) (*Connection, error)

NewUnsafe returns a new SQLX connection that will succeed scanning when one or more columns in a SQL result have no corresponding fields in the destination struct.

func (*Connection) Beginx

func (db *Connection) Beginx() (sqldb.Tx, error)

Beginx is an Exec that accepts named params (ex where id=:user_id)

func (*Connection) Close

func (db *Connection) Close() error

Close closes the database connection

func (*Connection) DSN

func (db *Connection) DSN() string

DSN returns the DSN used to create the connection

func (*Connection) SQL

func (db *Connection) SQL() *sql.DB

SQL returns the sql.DB object

type Queryable

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

Queryable represents the sqlx implementation of the Queryable interface

func NewQueryable

func NewQueryable(con sqlxQueryable) *Queryable

NewQueryable creates a new Queryable

func (*Queryable) Exec

func (db *Queryable) Exec(query string, args ...interface{}) (rowsAffected int64, err error)

Exec executes a SQL query and returns the number of rows affected

func (*Queryable) Get

func (db *Queryable) Get(dest interface{}, query string, args ...interface{}) error

Get is used to retrieve a single row An error (sql.ErrNoRows) is returned if the result set is empty.

func (*Queryable) NamedExec

func (db *Queryable) NamedExec(query string, arg interface{}) (rowAffected int64, err error)

NamedExec is an Exec that accepts named params (ex where id=:user_id)

func (*Queryable) NamedGet

func (db *Queryable) NamedGet(dest interface{}, query string, args interface{}) error

NamedGet is a Get() that accepts named params (ex where id=:user_id)

func (*Queryable) NamedSelect

func (db *Queryable) NamedSelect(dest interface{}, query string, args interface{}) error

NamedSelect is a Select() that accepts named params (ex where id=:user_id)

func (*Queryable) Select

func (db *Queryable) Select(dest interface{}, query string, args ...interface{}) error

Select is used to retrieve multiple rows

type Tx

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

Tx implements the db.Tx interface for sqlx

func NewTx

func NewTx(con *sqlx.DB) (*Tx, error)

NewTx create a new transaction

func (*Tx) Commit

func (con *Tx) Commit() error

Commit commits the transaction

func (*Tx) Rollback

func (con *Tx) Rollback() error

Rollback roll backs the transaction

Jump to

Keyboard shortcuts

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