Documentation
¶
Overview ¶
Package config gives access to the dbm configuration file and the ability to create connection strings in order to connect with the configured databases.
Index ¶
Constants ¶
const ( // CONFIG is the name of the configuration file. CONFIG = "config.toml" // DATA_DIR is the directory from ROOT where the database files live. DATA_DIR = "db" )
Variables ¶
var ( // AllConfigs is all the environments. AllConfigs Configuration // Current is the config of the requested environment. Current *DB )
Functions ¶
func Load ¶
Load loads a configuration from CWD/db/config.toml first, if it cannot find that, it attempts to find the VCS root and do VCSROOT/db/config.toml.
Types ¶
type Configuration ¶
Configuration is the type of the current config.
type DB ¶
type DB struct { Name string Kind string Host string User string Pass string SSL bool SSLSkipVerify bool }
DB is a database configuration.
func (*DB) DSN ¶
DSN creates a connection string from the database values given. Panics if DB doesn't have a kind of: "mysql", "postgres", or "sqlite3"
Different sql adapters will use different kinds of DSN strings. The strings generated here are useful with the following packages: MySQL: github.com/go-sql-driver/mysql Postgres: github.com/lib/pq Sqlite3: code.google.com/p/go-sqlite/go1/sqlite3
This will call DB.DSNSqlite3(useVcsRoot=true) if the kind is Sqlite3.
func (*DB) DSNSqlite3 ¶
DSNSqlite3 creates the filepath for a sqlite3 file. If the "name" from the config has the file path separator in it then no transformations will be done the path.
If there are no path separators then it will check the useVcsRoot value to determine which root directory to use (vcsRoot or cwd). In both cases the result will be ROOT/db/{name}.sqlite3