database

package
v0.0.0-...-44af80e Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Username  string `json:"Username" env:"DB_USERNAME"`
	Password  string `json:"Password" env:"DB_PASSWORD"`
	Database  string `json:"Database" env:"DB_DATABASE"`
	Charset   string `json:"Charset" env:"DB_CHARSET"`
	Collation string `json:"Collation" env:"DB_COLLATION"`
	Hostname  string `json:"Hostname" env:"DB_HOSTNAME"`
	Port      int    `json:"Port" env:"DB_PORT"`
	Parameter string `json:"Parameter" env:"DB_PARAMETER"`
}

Connection holds the details for the MySQL connection.

func (Connection) Connect

func (c Connection) Connect(specificDatabase bool) (*sqlx.DB, error)

Connect to the database.

func (Connection) Create

func (c Connection) Create(sql *sqlx.DB) error

Create a new database.

func (Connection) Drop

func (c Connection) Drop(sql *sqlx.DB) error

Drop a database.

type DBW

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

DBW is a database wrapper that provides helpful utilities.

func New

func New(db *sqlx.DB) *DBW

New returns a new database wrapper.

func (*DBW) Exec

func (d *DBW) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*DBW) Get

func (d *DBW) Get(dest interface{}, query string, args ...interface{}) error

Get using this DB. Any placeholder parameters are replaced with supplied args. An error is returned if the result set is empty.

func (*DBW) QueryRowScan

func (d *DBW) QueryRowScan(dest interface{}, query string, args ...interface{}) error

QueryRowScan returns a single result.

func (*DBW) Select

func (d *DBW) Select(dest interface{}, query string, args ...interface{}) error

Select using this DB. Any placeholder parameters are replaced with supplied args.

Jump to

Keyboard shortcuts

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