db

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDbDriverIsNotSupported is returned when the db driver is not supported
	ErrDbDriverIsNotSupported = errors.New("This db driver is not supported")

	// ErrWrongCastNotAMap is returned when a map is not a map[interface{}]interface{}
	ErrWrongCastNotAMap = errors.New("Could not cast record: not a map[interface{}]interface{}")

	// ErrKeyIsNotString is returned when a record is not of type string
	ErrKeyIsNotString = errors.New("Record map key is not string")
)
View Source
var ErrCouldNotConvertToTime = errors.New("Could not convert string to time")

ErrCouldNotConvertToTime is returns when a string is not a reconizable time format

Functions

This section is empty.

Types

type DbManager

type DbManager interface {
	BuildInsertSQL(schema string, table string, fields map[string]interface{}) (string, []interface{}, error)
	TruncateTable(schema string, table string) (sql.Result, error)
	Exec(sqlStr string, params []interface{}) (sql.Result, error)
}

type DbManagerFactory

type DbManagerFactory struct{}

func (DbManagerFactory) NewDbManager

func (dm DbManagerFactory) NewDbManager(driverName string, host string, port int16, username string, password string, dbName string) (DbManager, error)

type InsertError

type InsertError struct {
	Err    error
	SQL    string
	Params []interface{}
}

InsertError will be returned if any error happens on database while inserting the record

func (*InsertError) Error

func (e *InsertError) Error() string

type MySQL

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

MySQL Driver for MySQL and MariaDB

func (*MySQL) BuildInsertSQL

func (m *MySQL) BuildInsertSQL(schema string, table string, record map[string]interface{}) (sqlStr string, values []interface{}, err error)

BuildInsertSQL Convert a record map to a insert string

func (*MySQL) Exec

func (m *MySQL) Exec(sqlStr string, params []interface{}) (sql.Result, error)

func (*MySQL) TruncateTable

func (m *MySQL) TruncateTable(schema string, table string) (sql.Result, error)

type PgSQL

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

PgSQL Driver for PgSQL and MariaDB

func NewPgSQL

func NewPgSQL(connection *sql.DB) *PgSQL

NewPgSQL returns new PgSQL instance

func (*PgSQL) BuildInsertSQL

func (m *PgSQL) BuildInsertSQL(schema string, table string, record map[string]interface{}) (sqlStr string, values []interface{}, err error)

BuildInsertSQL Convert a record map to a insert string

func (*PgSQL) Exec

func (m *PgSQL) Exec(sqlStr string, params []interface{}) (sql.Result, error)

func (*PgSQL) TruncateTable

func (m *PgSQL) TruncateTable(schema string, table string) (sql.Result, error)

Jump to

Keyboard shortcuts

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