db

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSQLName

func GenerateSQLName() string

GenerateSQLName generates a unique safe name that can be used for a database or table name

func Open

func Open(ctx context.Context, cfg config.Database) (db *sql.DB, err error)

Open opens a connection to a database and retries until ctx.Done() The users must import all the necessary drivers before calling this function.

Types

type SQLBuilder added in v1.4.0

type SQLBuilder interface {

	// Select returns a SelectBuilder
	Select(columns ...string) squirrel.SelectBuilder

	// Insert returns a InsertBuilder
	Insert(into string) squirrel.InsertBuilder

	// Update returns a UpdateBuilder
	Update(table string) squirrel.UpdateBuilder

	// Delete returns a DeleteBuilder
	Delete(from string) squirrel.DeleteBuilder

	// RunWith sets the RunWith field for any child builders.
	RunWith(runner squirrel.BaseRunner) squirrel.StatementBuilderType
}

SQLBuilder describes a basic SQL builder using the squirrel library

type SQLDB

type SQLDB interface {
	// Query executes the given query as implemented by database/sql.Query.
	Query(string, ...interface{}) (*sql.Rows, error)
	// QueryContext executes a query that returns rows, typically a SELECT.
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	// QueryRow executes a query that is expected to return at most one row. QueryRow always returns a
	// non-nil value.
	QueryRow(string, ...interface{}) *sql.Row
	// QueryRowContext executes a query that is expected to return at most one row. QueryRow always
	// returns a non-nil value.
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
	// Exec executes a query without returning any rows.
	Exec(string, ...interface{}) (sql.Result, error)
	// ExecContext executes a query without returning any rows.
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
}

SQLDB is the standard SQL database interface which the standard library should have but it does not

type TraceableDB

type TraceableDB interface {
	SQLDB
	tracing.Tracer
}

TraceableDB is the SQL database wrapped with open tracing

func WrapWithTracing

func WrapWithTracing(db SQLDB) TraceableDB

WrapWithTracing Wraps a SQL database with open tracing and logging

Directories

Path Synopsis
null
Package null implements nullable sql fields that are safely marshalable from/to json and text.
Package null implements nullable sql fields that are safely marshalable from/to json and text.

Jump to

Keyboard shortcuts

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