...

Package mysql

import "golang.conradwood.net/go-easyops/mysql"
Overview
Index

Overview ▾

mysql database handler. the use of this package is discouraged.

sometimes it is necessary to connect to mysql databases. This package provides a managed way to do so. development is largely stopped on this package. the use of postgres package is encouraged instead.

Constants

const (
    DEFAULT_MAX_QUERY_MILLIS = 3000
)

func IsSQLSafe

func IsSQLSafe(txt string) bool

**** // Helpers /********* returns true if this string is sql safe (no special characters

type DB

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

func Open

func Open() (*DB, error)

call this once when you startup and cache the result only if there is an error you'll need to retry

func (*DB) ExecContext

func (d *DB) ExecContext(ctx context.Context, name string, query string, args ...interface{}) (sql.Result, error)

"name" will be used to provide timing information as prometheus metric.

func (*DB) QueryContext

func (d *DB) QueryContext(ctx context.Context, name string, query string, args ...interface{}) (*sql.Rows, error)

"name" will be used to provide timing information as prometheus metric.

func (*DB) QueryRowContext

func (d *DB) QueryRowContext(ctx context.Context, name string, query string, args ...interface{}) *sql.Row

discouraged use. QueryRow() does not provide an error on the query, nor do we get a good timing value. Use QueryContext() instead.