Documentation
¶
Index ¶
- Variables
- func Connect(cfg Config) (*sql.DB, error)
- func Connected(db *sql.DB) error
- func Downgrade(path, driver string, db *sql.DB) error
- func MustConnect(cfg Config) *sql.DB
- func Rollback(tx *sql.Tx)
- func Upgrade(path, driver string, db *sql.DB) error
- type Config
- type MysqlConfig
- type PostgresConfig
- type SqliteConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMigrationsFailed = errors.New("database migrations failed") ErrNotConnected = errors.New("not connected to database") )
Common errors
Functions ¶
func MustConnect ¶
MustConnect establishes and tests a new database connection, and panics on errors.
Types ¶
type MysqlConfig ¶
type MysqlConfig struct {
Protocol string `json:"protocol"`
Host string `json:"host"`
Port string `json:"port"`
User string `json:"username"`
Password string `json:"password"`
Database string `json:"database"`
ConnectionParams string `json:"connectionParams"`
}
MysqlConfig configuration info for a MySQL databse.
func (MysqlConfig) Driver ¶
func (cfg MysqlConfig) Driver() string
Driver gets the SQLite driver name.
type PostgresConfig ¶
type PostgresConfig struct {
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
Database string `json:"database,omitempty"`
SSLMode string `json:"sslMode,omitempty"`
BinaryParamters string `json:"binaryParamters,omitempty"`
}
PostgresConfig configuration info for a MySQL databse.
func (PostgresConfig) Driver ¶
func (cfg PostgresConfig) Driver() string
Driver gets the SQLite driver name.
type SqliteConfig ¶
SqliteConfig configuration info for a SQLite databse.
func (SqliteConfig) Driver ¶
func (cfg SqliteConfig) Driver() string
Driver gets the SQLite driver name.
Click to show internal directories.
Click to hide internal directories.