Documentation
¶
Index ¶
Constants ¶
const ( // Postgres is the postgres string Postgres = "postgres" // MySql is the mysql string MySql = "mysql" // SQLite is the sqlite3 string SQLite = "sqlite3" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Encoding string `yaml:"encoding" json:"encoding"` Adapter string `yaml:"adapter" json:"adapter"` Database string `yaml:"database" json:"database"` Host string `yaml:"host" json:"host"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` Port int `yaml:"port" json:"port"` Socket string `yaml:"socket" json:"socket"` Name string `yaml:"name" json:"name"` }
Config is the base configuration struct for all database configurations. It is embedded in the more specific config types, PGConfig, MySqlConfig, and SQLiteConfig
func (*Config) GetAdapter ¶
GetAdapter returns the adapter being used for this configuration.
type MySQLConfig ¶
type MySQLConfig struct { Config `yaml:",inline"` Protocol string `yaml:"protocol" json:"protocol"` }
MySQLConfig represents a MySql database configuration struct
func MySqlConfigFromConfig ¶
func MySqlConfigFromConfig(config Config) *MySQLConfig
MySqlConfigFromConfig returns a pointer to a MySQLConfig with default values
func NewMySqlConfig ¶
func NewMySqlConfig() *MySQLConfig
NewMySqlConfig returns a pointer to a MySql configuration struct with UseDefaults set to true
func (*MySQLConfig) Open ¶
func (m *MySQLConfig) Open() (*sqlx.DB, error)
open assembles a datasource string and attempts to open a connection to a MySQL server
func (*MySQLConfig) SetDefaults ¶
func (m *MySQLConfig) SetDefaults()
SetDefaults sets default MySQL settings
type Opener ¶
type Opener interface { // Sets all defaults for the particular type of database configuration SetDefaults() // Opens a connection to a database Open() (*sqlx.DB, error) // Returns the Name of the current database configuration GetName() string // Returns the Adapter of the interface GetAdapter() string }
Opener is an interface that can open a connection to a database
type PGConfig ¶
type PGConfig struct { Config `yaml:",inline"` SSLMode string `yaml:"ssl_mode" json:"ssl_mode"` ConnectionTimeout int `yaml:"connection_timeout" json:"connection_timeout"` }
PGConfig represents a Postgres configuration struct
func NewPGConfig ¶
func NewPGConfig() *PGConfig
NewPGConfig returns a pointer to a postgres configuration struct with UseDefaults set to true
func PGConfigFromConfig ¶
PGConfigFromConfig sets defaults specific to postgres.
func (*PGConfig) Open ¶
open assembles a datasource string and attempts to open a connection to a postgres/redshift server
func (*PGConfig) SetDefaults ¶
func (pg *PGConfig) SetDefaults()
SetDefaults sets defaults specific to postgres.
type SQLiteConfig ¶
type SQLiteConfig struct {
Config `yaml:",inline"`
}
SQLiteConfig represents a SQLite configuration
func NewSQLiteConfig ¶
func NewSQLiteConfig() *SQLiteConfig
NewSQLiteConfig returns a SQliteConfig struct with UseDefaults set to true
func SQLiteConfigFromConfig ¶
func SQLiteConfigFromConfig(config Config) *SQLiteConfig
SQLiteConfigFromConfig returns a *SQLiteConfig with defaults
func (*SQLiteConfig) Open ¶
func (lite *SQLiteConfig) Open() (*sqlx.DB, error)
open pens a connection to the SQLite database
func (*SQLiteConfig) SetDefaults ¶
func (lite *SQLiteConfig) SetDefaults()
SetDefaults sets SQLite default settings