Documentation ¶
Index ¶
- Variables
- type DB
- type DBAdapter
- type MSSQLAdapter
- func (m MSSQLAdapter) ConvertGenericPlaceholders(query string, argsCount int) string
- func (m MSSQLAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
- func (m MSSQLAdapter) DatabaseName(executor sqlExecutor) (string, error)
- func (m MSSQLAdapter) TableExists(executor sqlExecutor, tableName string) (bool, error)
- type MySQLAdapter
- func (m MySQLAdapter) ConvertGenericPlaceholders(query string, argsCount int) string
- func (m MySQLAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
- func (m MySQLAdapter) DatabaseName(executor sqlExecutor) (string, error)
- func (m MySQLAdapter) TableExists(executor sqlExecutor, tableName string) (bool, error)
- type PostgresqlAdapter
- func (p PostgresqlAdapter) ConvertGenericPlaceholders(query string, argsCount int) string
- func (p PostgresqlAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
- func (p PostgresqlAdapter) DatabaseName(executor sqlExecutor) (string, error)
- func (p PostgresqlAdapter) TableExists(executor sqlExecutor, tableName string) (bool, error)
- type SqlDB
- func (db SqlDB) Close() error
- func (db SqlDB) Exec(query string, args ...any) (sql.Result, error)
- func (db SqlDB) Query(query string, args ...any) (*sql.Rows, error)
- func (db SqlDB) QueryRow(query string, args ...any) *sql.Row
- func (db SqlDB) TableExists(tableName string) (bool, error)
- func (db SqlDB) Tx(fn TxFunc) error
- type SqliteAdapter
- func (s SqliteAdapter) ConvertGenericPlaceholders(query string, argsCount int) string
- func (s SqliteAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
- func (s SqliteAdapter) DatabaseName(executor sqlExecutor) (string, error)
- func (s SqliteAdapter) TableExists(executor sqlExecutor, tableName string) (bool, error)
- type TxFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMalformedConnectionString = errors.New( "malformed database connection parameters provided", ) ErrUnableToConnect = errors.New("unable to open connection to database") ErrUnsupportedDriver = fmt.Errorf( "unsupported driver, supported drivers are %s", []string{ postgresqlDriverName, mysqlDriverName, mssqlDriverName, sqliteDriverName, }, ) )
Functions ¶
This section is empty.
Types ¶
type DB ¶ added in v0.5.0
type DB interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row Tx(fn TxFunc) error Close() error TableExists(tableName string) (bool, error) }
func NewDB ¶ added in v0.5.0
func NewDB(cfg configloader.ConnectionConfig) (DB, error)
NewDB establishes a connection to the database using the connection configuration.
The following errors may be returned:
- ErrMalformedConnectionString: The provided connection parameters are not in a valid format.
- ErrUnableToConnect: Unable to make a connection to the database with the provided connection parameters.
- ErrUnsupportedDriver: The provided driver is not supported.
type DBAdapter ¶ added in v0.5.0
type DBAdapter interface { // ConvertGenericPlaceholders replaces any generic `?` placeholders // in `query` for the database driver specific placeholders and returns // the updated query. ConvertGenericPlaceholders(query string, argsCount int) string // TableExists checks if the tableName exists within the // database currently connected to. TableExists(executor sqlExecutor, tableName string) (bool, error) // DatabaseName retrieves the currently selected database name. DatabaseName(executor sqlExecutor) (string, error) // CreateDSN creates a DSN to be used with sql.Open in the database // driver specific format. CreateDSN(cfg configloader.ConnectionConfig) string }
type MSSQLAdapter ¶ added in v0.6.0
type MSSQLAdapter struct{}
func (MSSQLAdapter) ConvertGenericPlaceholders ¶ added in v0.6.0
func (m MSSQLAdapter) ConvertGenericPlaceholders( query string, argsCount int, ) string
func (MSSQLAdapter) CreateDSN ¶ added in v0.6.0
func (m MSSQLAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
func (MSSQLAdapter) DatabaseName ¶ added in v0.6.0
func (m MSSQLAdapter) DatabaseName(executor sqlExecutor) (string, error)
func (MSSQLAdapter) TableExists ¶ added in v0.6.0
func (m MSSQLAdapter) TableExists( executor sqlExecutor, tableName string, ) (bool, error)
type MySQLAdapter ¶ added in v0.5.0
type MySQLAdapter struct{}
func (MySQLAdapter) ConvertGenericPlaceholders ¶ added in v0.5.0
func (m MySQLAdapter) ConvertGenericPlaceholders(query string, argsCount int) string
func (MySQLAdapter) CreateDSN ¶ added in v0.5.0
func (m MySQLAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
func (MySQLAdapter) DatabaseName ¶ added in v0.5.0
func (m MySQLAdapter) DatabaseName(executor sqlExecutor) (string, error)
func (MySQLAdapter) TableExists ¶ added in v0.5.0
func (m MySQLAdapter) TableExists( executor sqlExecutor, tableName string, ) (bool, error)
type PostgresqlAdapter ¶ added in v0.5.0
type PostgresqlAdapter struct{}
func (PostgresqlAdapter) ConvertGenericPlaceholders ¶ added in v0.5.0
func (p PostgresqlAdapter) ConvertGenericPlaceholders( query string, argsCount int, ) string
func (PostgresqlAdapter) CreateDSN ¶ added in v0.5.0
func (p PostgresqlAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
func (PostgresqlAdapter) DatabaseName ¶ added in v0.5.0
func (p PostgresqlAdapter) DatabaseName(executor sqlExecutor) (string, error)
func (PostgresqlAdapter) TableExists ¶ added in v0.5.0
func (p PostgresqlAdapter) TableExists( executor sqlExecutor, tableName string, ) (bool, error)
type SqlDB ¶ added in v0.10.0
type SqlDB struct {
// contains filtered or unexported fields
}
func (SqlDB) Close ¶ added in v0.10.0
Close closes the database connection. Any further queries will result in errors, and you should call NewDB again after if you'd like to run more.
func (SqlDB) TableExists ¶ added in v0.10.0
TableExists checks if the tableName exists within the database currently connected to.
type SqliteAdapter ¶ added in v0.6.0
type SqliteAdapter struct{}
func (SqliteAdapter) ConvertGenericPlaceholders ¶ added in v0.6.0
func (s SqliteAdapter) ConvertGenericPlaceholders( query string, argsCount int, ) string
func (SqliteAdapter) CreateDSN ¶ added in v0.6.0
func (s SqliteAdapter) CreateDSN(cfg configloader.ConnectionConfig) string
func (SqliteAdapter) DatabaseName ¶ added in v0.6.0
func (s SqliteAdapter) DatabaseName(executor sqlExecutor) (string, error)
func (SqliteAdapter) TableExists ¶ added in v0.6.0
func (s SqliteAdapter) TableExists( executor sqlExecutor, tableName string, ) (bool, error)
Click to show internal directories.
Click to hide internal directories.