Documentation ¶
Overview ¶
Package gorpx manages connections to multiple datasources (i.e. one sqlite3, another mysql) and keeps a map for each datasource with connection pool and a data dict mapper. The mapping of tables is then application specific. Data definition stuff is then application specific. Data modification stuff is then application specific.
Index ¶
- func CheckRes(sqlRes sql.Result, err error)
- func Concat(dbType string, args ...string) string
- func Db(optDataSourceID ...int) *sql.DB
- func Db2Map() *gorp.DbMap
- func Db2TableName(i interface{}) string
- func DbClose(optDataSourceID ...int)
- func DbMap(optDataSourceID ...int) *gorp.DbMap
- func DbTableName(i interface{}, optDataSourceID ...int) string
- func IndependentDbMapper(optDataSourceID ...int) *gorp.DbMap
- func IndependentDbMapperFunc(idx int) func() *gorp.DbMap
- func SetAndInitDatasourceId(hosts SQLHosts, dataSourceId int)
- func TraceOff()
- func TraceOn()
- func Type(optDataSourceID ...int) string
- type SQLHost
- type SQLHosts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Db2TableName ¶
func Db2TableName(i interface{}) string
Db2TableName returns the table name from the second data source index
func DbMap ¶
DbMap returns default DB Map, that is being reused on each DB operation. On the first call, a default map is created anew. The DB default map can then be mapped to the application specific tables like this:
func MapAllTables(argDbMap *gorp.DbMap) { argDbMap.AddTableWithName(paramgroup.ParamGroup{}, "paramgroup") argDbMap.AddTable(pivot.Pivot{}) : }
func DbTableName ¶
DbTableName - for fun and confusion, the table names are in lower case or title case, depending on windows/linux and mysql/sqlite3. It depends on the MySQL server settings, whether it objects to wrong case. We cannot take any chances, we must derive the table name dynamical:
func IndependentDbMapper ¶
IndependentDbMapper creates a new DB Mapper on each call. Because for instance EnablePlainInserts() creates irreversible changes to a DB map, and we need a new one afterwards.
func IndependentDbMapperFunc ¶
IndependentDbMapperFunc for some operations who need several DB mappers in a row. For this, we have a DB mapper "factory".
func SetAndInitDatasourceId ¶
SetAndInitDatasourceId - the key to SQLHosts config is given either
by environment variable DATASOURCEX
or set to default "dsnX" or explicitly submitted as optional key (i.e. for temporary backups)
The resulting connection is then set as data source id x. data source id 0 is the default. data source id 1 is the target for comparisons. data source id 2 is for backups
Types ¶
type SQLHost ¶
type SQLHost struct { Type string `json:"type"` // sqlite3 User string `json:"user"` Host string `json:"host"` Port string `json:"port"` DbName string `json:"db_name"` // also sqlite3 filename ConnectionParams map[string]string `json:"connection_params"` }
SQLHost represents DB resource