Documentation ¶
Index ¶
- Constants
- func PrepareBatchInsertColumns(rowCount int, columnCount int) string
- func PrepareInsertColumn(columnCount int) string
- type Client
- func (c Client) CleanUp() error
- func (c Client) ConnCheck() (bool, error)
- func (c Client) ConnCheckWithContext(ctx context.Context) (bool, error)
- func (c Client) Exec(query string, params []interface{}) (sql.Result, error)
- func (c Client) ExecWithContext(ctx context.Context, query string, params []interface{}) (sql.Result, error)
- func (c Client) GetStats() (sql.DBStats, error)
- func (c Client) Migrate() error
- func (c Client) Prepare(query string) (*sql.Stmt, error)
- func (c Client) PrepareWithContext(ctx context.Context, query string) (*sql.Stmt, error)
- func (c Client) Query(query string, params []interface{}) (*sql.Rows, error)
- func (c Client) QueryRow(query string, params []interface{}) (*sql.Row, error)
- func (c Client) QueryRowWithContext(ctx context.Context, query string, params []interface{}) (*sql.Row, error)
- func (c Client) QueryWithContext(ctx context.Context, query string, params []interface{}) (*sql.Rows, error)
- func (c Client) StmtExec(stmt *sql.Stmt, params []interface{}) (sql.Result, error)
- func (c Client) StmtExecWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (sql.Result, error)
- func (c Client) StmtQuery(stmt *sql.Stmt, params []interface{}) (*sql.Rows, error)
- func (c Client) StmtQueryRow(stmt *sql.Stmt, params []interface{}) *sql.Row
- func (c Client) StmtQueryRowWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) *sql.Row
- func (c Client) StmtQueryWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (*sql.Rows, error)
- func (c Client) TxBegin() (*sql.Tx, error)
- func (c Client) TxBeginWithContext(ctx context.Context) (*sql.Tx, error)
- func (c Client) TxCommit(tx *sql.Tx) error
- func (c Client) TxExec(tx *sql.Tx, query string, params []interface{}) (sql.Result, error)
- func (c Client) TxExecWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) (sql.Result, error)
- func (c Client) TxQuery(tx *sql.Tx, query string, params []interface{}) (*sql.Rows, error)
- func (c Client) TxQueryRow(tx *sql.Tx, query string, params []interface{}) *sql.Row
- func (c Client) TxQueryRowWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) *sql.Row
- func (c Client) TxQueryWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) (*sql.Rows, error)
- func (c Client) TxRollback(tx *sql.Tx) error
- type Config
- type Datastore
Constants ¶
const DefaultMigrationDir = "./internal/database/migration/sql"
DefaultMigrationDir Default directory for migration sql files
const MaxIdleConns = 5
MaxIdleConns maximum idle connections
const MaxIdleConnsTime = 1 * time.Second
MaxIdleConnsTime maximum idle connection timeout
const MaxOpenConns = 10
MaxOpenConns maximum open connections
const MaxOpenConnsTime = 30 * time.Second
MaxOpenConnsTime maximum connection timeout
Variables ¶
This section is empty.
Functions ¶
func PrepareBatchInsertColumns ¶ added in v0.1.3
PrepareBatchInsertColumns prepares (?,?,?),(?,?,?),(?,?,?)
func PrepareInsertColumn ¶ added in v0.1.3
PrepareInsertColumn prepares (?,?,?)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client ...
func (Client) ConnCheckWithContext ¶ added in v0.4.0
ConnCheck check if connection exists
func (Client) ExecWithContext ¶ added in v0.4.0
func (c Client) ExecWithContext(ctx context.Context, query string, params []interface{}) (sql.Result, error)
ExecWithContext ...
func (Client) PrepareWithContext ¶ added in v0.4.0
PrepareWithContext Prepare query
func (Client) QueryRowWithContext ¶ added in v0.4.0
func (c Client) QueryRowWithContext(ctx context.Context, query string, params []interface{}) (*sql.Row, error)
QueryRowWithContext Execute query and returns single row
func (Client) QueryWithContext ¶ added in v0.4.0
func (c Client) QueryWithContext(ctx context.Context, query string, params []interface{}) (*sql.Rows, error)
QueryWithContext queries multiple rows
func (Client) StmtExecWithContext ¶ added in v0.4.0
func (c Client) StmtExecWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (sql.Result, error)
StmtExecWithContext Execute query
func (Client) StmtQueryRow ¶ added in v0.1.2
StmtQueryRow Execute query and returns single row
func (Client) StmtQueryRowWithContext ¶ added in v0.4.0
func (c Client) StmtQueryRowWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) *sql.Row
StmtQueryRowWithContext Execute query and returns single row
func (Client) StmtQueryWithContext ¶ added in v0.4.0
func (c Client) StmtQueryWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (*sql.Rows, error)
StmtQueryWithContext queries multiple rows
func (Client) TxBeginWithContext ¶ added in v0.4.0
TxBeginWithContext Start and return transaction
func (Client) TxExecWithContext ¶ added in v0.4.0
func (c Client) TxExecWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) (sql.Result, error)
TxExecWithContext Execute query
func (Client) TxQueryRow ¶ added in v0.1.2
TxQueryRow Execute query and returns single row
func (Client) TxQueryRowWithContext ¶ added in v0.4.0
func (c Client) TxQueryRowWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) *sql.Row
TxQueryRowWithContext Execute query and returns single row
type Config ¶
type Config struct { DBHost string DBPort string DBUser string DBPass string DBName string DBSSL string DBTimeout string DBCharset string DBCollation string MigrationDir string MigrationsTable string ParaseTime string MaxOpenConns int MaxIdleConns int MaxOpenConnsTime time.Duration MaxIdleConnsTime time.Duration NewrelicEnabled bool }
Config ...
type Datastore ¶
type Datastore interface { ConnCheck() (bool, error) GetStats() Query(query string, params []interface{}) (*sql.Rows, error) QueryRow(query string, params []interface{}) (*sql.Row, error) Exec(query string, params []interface{}) (sql.Result, error) QueryWithContext(ctx context.Context, query string, params []interface{}) (*sql.Rows, error) QueryRowWithContext(ctx context.Context, query string, params []interface{}) (*sql.Row, error) ExecWithContext(ctx context.Context, query string, params []interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) StmtQuery(stmt *sql.Stmt, params []interface{}) (*sql.Rows, error) StmtQueryRow(stmt *sql.Stmt, params []interface{}) *sql.Row StmtExec(stmt *sql.Stmt, params []interface{}) (sql.Result, error) PrepareWithContext(ctx context.Context, query string) (*sql.Stmt, error) StmtQueryWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (*sql.Rows, error) StmtQueryRowWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) *sql.Row StmtExecWithContext(ctx context.Context, stmt *sql.Stmt, params []interface{}) (sql.Result, error) BeginTx() (*sql.Tx, error) TxPrepare(tx *sql.Tx, query string) (*sql.Stmt, error) TxQuery(tx *sql.Tx, query string, params []interface{}) (*sql.Rows, error) TxQueryRow(tx *sql.Tx, query string, params []interface{}) *sql.Row TxExec(tx *sql.Tx, query string, params []interface{}) (sql.Result, error) TxCommit(tx *sql.Tx) error TxRollback(tx *sql.Tx) error BeginTxWithContext(ctx context.Context) (*sql.Tx, error) TxPrepareWithContext(ctx context.Context, tx *sql.Tx, query string) (*sql.Stmt, error) TxQueryWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) (*sql.Rows, error) TxQueryRowWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) *sql.Row TxExecWithContext(ctx context.Context, tx *sql.Tx, query string, params []interface{}) (sql.Result, error) Migrate() error // contains filtered or unexported methods }
Datastore ...