Documentation ¶
Index ¶
- type Config
- func (c *Config) Close() error
- func (c *Config) MultiQuery(sql []string, args ...[]interface{}) ([][]map[string]interface{}, error)
- func (c *Config) Open() error
- func (c *Config) Ping() error
- func (c *Config) PrepareTest(sql string) error
- func (c *Config) Query(sql string, args ...interface{}) ([]map[string]interface{}, error)
- func (c *Config) QueryInterface(sql string, args ...interface{}) ([]map[string]interface{}, error)
- func (c *Config) QueryString(sql string, args ...interface{}) ([]map[string]string, error)
- func (c *Config) Transaction(sqls []string, args ...[][]interface{}) error
- func (c *Config) Unmarshal(v interface{}, SQL string, args ...interface{}) error
- func (c *Config) UnmarshalReadOnly(v interface{}, SQL string, args ...interface{}) error
- func (c *Config) UnmarshalWithOptions(txOpts *sql.TxOptions, v interface{}, SQL string, args ...interface{}) error
- func (c *Config) Upsert(sql string, array [][]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Database name Name string `yaml:"name" json:"name"` // Database user name User string `yaml:"user" json:"user"` // Database password can be one of: // 1) password text // 2) pointer to a file containing the password: file:/path/to/secret.pw // 3) an environment variable containing the password: env:PASSWORD_ENV Password string `yaml:"password" json:"password"` // SSLMode: disable,allow,prefer,require,verify-ca,verify-full. Default: disable SSLMode string `yaml:"sslmode" json:"sslmode"` // Driver, only postgresql (the default) is tested. Driver string `yaml:"driver" json:"driver"` // Hostname can be a hostname or a path to a socket. Defaults to /var/run/postgresql Host string `yaml:"host" json:"host"` // Maximum open connections MaxOpenConns int `yaml:"maxOpenConns"` // Maximum idle connections MaxIdleConns int `yaml:"maxIdleConns"` // contains filtered or unexported fields }
Config holds the connection string parameters and handler
func (*Config) MultiQuery ¶
func (c *Config) MultiQuery(sql []string, args ...[]interface{}) ([][]map[string]interface{}, error)
MultiQuery takes a SQL list and data list (paired), and returns set of rows with string map to interfaces values.
func (*Config) Open ¶
Open initialize a configuration. An error is returned if the initializing failed.
func (*Config) PrepareTest ¶
PrepareTest test a sql, and returns an error if it fails.
func (*Config) Query ¶
Query takes an SQL and data, and returns rows with string map to interfaces values.
func (*Config) QueryInterface ¶
QueryInterface takes an SQL and data, and returns rows with string map to interfaces values.
func (*Config) QueryString ¶
QueryString takes an SQL and data, and returns rows with string map to stringified values.
func (*Config) Transaction ¶
Transaction takes a SQL list and an array list of values for transactions. of rows with string map to interfaces values.
func (*Config) Unmarshal ¶
Unmarshal rows into a slice with pointers to a struct. The mapping between row columns and struct fields are done with field tags named dbi. When getting dates from the database, the pq modules returnes a date format looking very much like a timestamp including time and time zone. To get rid of this, the unmarshaler can strip away the time part if the field type is a string and the option date is specified after the column name. Example. `dbi:"date,date"`
func (*Config) UnmarshalReadOnly ¶ added in v0.1.4
UnmarshalReadOnly rows into a slice with pointers to a struct. The mapping between row columns and struct fields are done with field tags named dbi. When getting dates from the database, the pq modules returnes a date format looking very much like a timestamp including time and time zone. To get rid of this, the unmarshaler can strip away the time part if the field type is a string and the option date is specified after the column name. Example. `dbi:"date,date"`
func (*Config) UnmarshalWithOptions ¶ added in v0.1.4
func (c *Config) UnmarshalWithOptions(txOpts *sql.TxOptions, v interface{}, SQL string, args ...interface{}) error
UnmarshalWithOptions rows into a slice with pointers to a struct. The mapping between row columns and struct fields are done with field tags named dbi. When getting dates from the database, the pq modules returnes a date format looking very much like a timestamp including time and time zone. To get rid of this, the unmarshaler can strip away the time part if the field type is a string and the option date is specified after the column name. Example. `dbi:"date,date"`