db

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverSQLServer = "mssql"
	DriverMySQL     = "mysql"
)

Defines all possible sql drivers

Variables

This section is empty.

Functions

func DriverName

func DriverName() string

DriverName - Returns driver name

func GetSQLXFromSQLConnector added in v1.3.1

func GetSQLXFromSQLConnector(db SQLConnector) *sqlx.DB

GetSQLXFromSQLConnector - Returns a ptr of sqlx.DB from a SQLConnector

func InitConnection

func InitConnection(drvName string, connection string)

InitConnection - Initialize the connection with driver and connection string

func Query

func Query(query string, args ...interface{}) (*sqlx.Rows, error)

Query - Executes the query and return a *Rows instance

func QueryOrPanic

func QueryOrPanic(query string, args ...interface{}) *sqlx.Rows

QueryOrPanic - Executes the query and return a *Rows instance, panics if error occurs

func TableExists

func TableExists(tableName string) bool

TableExists - Returns true if table exists otherwise false

Types

type SQLConnector

type SQLConnector interface {
	DriverName() string
	Exec(string, ...interface{}) (sql.Result, error)
	Prepare(string) (*sql.Stmt, error)
	Preparex(string) (*sqlx.Stmt, error)
	Query(string, ...interface{}) (*sql.Rows, error)
	Queryx(string, ...interface{}) (*sqlx.Rows, error)
	QueryRow(string, ...interface{}) *sql.Row
	QueryRowx(string, ...interface{}) *sqlx.Row
}

SQLConnector - Generalizes a sql connection

func GetConnection

func GetConnection() SQLConnector

GetConnection - Returns an instance of the db connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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