Documentation ¶
Index ¶
- Constants
- func DriverName() string
- func DriverNameByKey(key string) (string, error)
- func GetSQLXFromSQLConnector(db SQLConnector) *sqlx.DB
- func InitConnection(drvName string, connection string)
- func InitConnectionWithKey(key string, drvName string, connection string)
- func Query(query string, args ...interface{}) (*sqlx.Rows, error)
- func QueryOrPanic(query string, args ...interface{}) *sqlx.Rows
- func QueryOrPanicWithKey(key string, query string, args ...interface{}) *sqlx.Rows
- func QueryWithKey(key string, query string, args ...interface{}) (*sqlx.Rows, error)
- func TableExists(tableName string) bool
- func TableExistsWithKey(key string, tableName string) bool
- type InvalidConnectionKeyError
- type SQLConnector
Constants ¶
const ( DriverSQLServer = "mssql" DriverMySQL = "mysql" )
Defines all possible sql drivers
const DefaultConnectionName = "default"
DefaultConnectionName - default connection key
Variables ¶
This section is empty.
Functions ¶
func DriverNameByKey ¶ added in v1.5.1
DriverNameByKey - Returns driver name for the connection key provided
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 InitConnectionWithKey ¶ added in v1.5.1
InitConnectionWithKey - Initialize the connection for specific key with driver and connection string
func QueryOrPanic ¶
QueryOrPanic - Executes the query and return a *Rows instance, panics if error occurs
func QueryOrPanicWithKey ¶ added in v1.5.1
QueryOrPanicWithKey - Executes the query for a specific connection key and return a *Rows instance, panics if error occurs
func QueryWithKey ¶ added in v1.5.1
QueryWithKey - Executes the query for a specific connection key and return a *Rows instance
func TableExists ¶
TableExists - Returns true if table exists otherwise false
func TableExistsWithKey ¶ added in v1.5.1
TableExistsWithKey - Returns true if table exists otherwise false for a specific connection key
Types ¶
type InvalidConnectionKeyError ¶ added in v1.5.1
type InvalidConnectionKeyError struct {
// contains filtered or unexported fields
}
InvalidConnectionKeyError - Defines the error for an invalid key provided to retrive or use a connection instance
func NewInvalidConnectionKeyError ¶ added in v1.5.1
func NewInvalidConnectionKeyError(msg string) *InvalidConnectionKeyError
NewInvalidConnectionKeyError - Returns a new InvalidConnectionKeyError instance
func (*InvalidConnectionKeyError) Error ¶ added in v1.5.1
func (e *InvalidConnectionKeyError) Error() string
Error - Implements error interface
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 the default instance of db connection
func GetConnectionWithKey ¶ added in v1.5.1
func GetConnectionWithKey(key string) (SQLConnector, error)
GetConnectionWithKey - Returns an istance of the db connection by connection key (for multiple connections)