Documentation ¶
Index ¶
- Constants
- func DriverName() string
- func GetSQLXFromSQLConnector(db SQLConnector) *sqlx.DB
- func InitConnection(drvName string, connection string)
- func Query(query string, args ...interface{}) (*sqlx.Rows, error)
- func QueryOrPanic(query string, args ...interface{}) *sqlx.Rows
- func TableExists(tableName string) bool
- type SQLConnector
Constants ¶
View Source
const ( DriverSQLServer = "mssql" DriverMySQL = "mysql" )
Defines all possible sql drivers
Variables ¶
This section is empty.
Functions ¶
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 ¶
InitConnection - Initialize the connection with driver and connection string
func QueryOrPanic ¶
QueryOrPanic - Executes the query and return a *Rows instance, panics if error occurs
func TableExists ¶
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
Click to show internal directories.
Click to hide internal directories.