Documentation ¶
Index ¶
- Variables
- func Connect(driver string, params map[string]interface{}) (*sqlx.DB, error)
- func EncodeCSV(w io.Writer, i *Iterator) error
- func EncodeJSON(w io.Writer, i *Iterator) error
- func EncodeLDJSON(w io.Writer, i *Iterator) error
- func PersistentConnect(driver string, params map[string]interface{}) (*sqlx.DB, error)
- func Shutdown()
- type Encoder
- type Iterator
- type Record
Constants ¶
This section is empty.
Variables ¶
var ( MaxIdleConns = 10 MaxConnLifetime = 10 * time.Minute )
var Drivers = map[string]string{
"postgresql": "postgres",
"postgres": "postgres",
"mysql": "mysql",
"mariadb": "mysql",
"sqlite": "sqlite3",
"mssql": "mssql",
"sqlserver": "mssql",
"oracle": "oci8",
"snowflake": "snowflake",
"odbc": "odbc",
"presto": "presto",
}
Drivers contains a map of public driver names to registered driver names.
var ErrUnknownDriver = errors.New("sqlagent: Unknown driver")
ErrUnknownDriver is returned when an unknown driver is used when attempting to connect.
Functions ¶
func Connect ¶
Connect connects to a database given a driver name and set of connection parameters. Each database supports a different set of connection parameters, however the few that are common are standardized.
- `host` - The database host. - `port` - The database port. - `user` - The username to authenticate with. - `password` - The password to authenticate with. - `database` - The database to connect to.
Other known database-specific parameters will be appended to the connection string and the remaining will be ignored.
func EncodeJSON ¶
EncodeJSON encodes the iterator as a JSON array of records.
func EncodeLDJSON ¶
EncodeLDJSON encodes the iterator as a line delimited stream of records.
func PersistentConnect ¶
Types ¶
type Iterator ¶
type Iterator struct { Cols []string // contains filtered or unexported fields }
Iterator provides a lazy access to the database rows.
func Execute ¶
Execute takes a database instance, SQL statement, and parameters and executes the query returning the resulting rows.