database

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package database contains functions to simplify opening/closing of DB connections, and tracing of SQL queries

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDBConnection

func CloseDBConnection(db *sqlx.DB)

CloseDBConnection closes specified database connection.

func CloseSQLConnection

func CloseSQLConnection(conn *sqlx.Conn)

CloseSQLConnection closes the specified database connection.

func OpenDBConnection

func OpenDBConnection(dsn, driver, user, passwd, host, schema, sslMode string) (*sqlx.DB, error)

OpenDBConnection establishes a connection specified database.

func SetDBOptionsAndPing

func SetDBOptionsAndPing(db *sqlx.DB) error

SetDBOptionsAndPing configures DB connections and attempts to ping it.

Types

type DBQueryContext added in v0.3.0

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

func NewDBSelectContext added in v0.3.0

func NewDBSelectContext(s *zap.SugaredLogger, conn *sqlx.Conn, trace bool) *DBQueryContext

NewDBSelectContext creates a new instance of the DBQueryContext service.

func (*DBQueryContext) SQLQueryTrace added in v0.3.0

func (q *DBQueryContext) SQLQueryTrace(query string, args ...interface{})

SQLQueryTrace logs the given SQL query if debug is enabled.

func (*DBQueryContext) SQLResultsTrace added in v0.3.0

func (q *DBQueryContext) SQLResultsTrace(results interface{})

SQLResultsTrace logs the given SQL result if debug is enabled.

func (*DBQueryContext) SelectContext added in v0.3.0

func (q *DBQueryContext) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

SelectContext logs the give query before executing it and the result afterward, if tracing is enabled?

Jump to

Keyboard shortcuts

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