Documentation ¶
Overview ¶
Package sqldb defines an interface for low level db connection.
Package sqldb defines an interface for low level db connection
Index ¶
- Constants
- func ExecuteFetchMap(conn Conn, query string) (map[string]string, error)
- func GetCharset(conn Conn) (*binlogdatapb.Charset, error)
- func NewSQLErrorFromError(err error) error
- func Register(name string, fn NewConnFunc)
- func RegisterDefault(fn NewConnFunc)
- func SetCharset(conn Conn, cs *binlogdatapb.Charset) error
- type Conn
- type ConnParams
- type NewConnFunc
- type SQLError
Constants ¶
const (
// SQLStateGeneral is the SQLSTATE value for "general error".
SQLStateGeneral = "HY000"
)
Variables ¶
This section is empty.
Functions ¶
func ExecuteFetchMap ¶
ExecuteFetchMap returns a map from column names to cell data for a query that should return exactly 1 row.
func GetCharset ¶
func GetCharset(conn Conn) (*binlogdatapb.Charset, error)
GetCharset returns the current numerical values of the per-session character set variables.
func NewSQLErrorFromError ¶
NewSQLErrorFromError returns a *SQLError from the provided error. If it's not the right type, it still tries to get it from a regexp.
func RegisterDefault ¶
func RegisterDefault(fn NewConnFunc)
RegisterDefault registers the default connection function. Only one default can be registered.
func SetCharset ¶
func SetCharset(conn Conn, cs *binlogdatapb.Charset) error
SetCharset changes the per-session character set variables.
Types ¶
type Conn ¶
type Conn interface { // ExecuteFetch executes the query on the connection ExecuteFetch(query string, maxrows int, wantfields bool) (*sqltypes.Result, error) // ExecuteStreamFetch starts a streaming query to db server. Use FetchNext // on the Connection until it returns nil or error ExecuteStreamFetch(query string) error // Close closes the db connection Close() // IsClosed returns if the connection was ever closed IsClosed() bool // CloseResult finishes the result set CloseResult() // Fields returns the current fields description for the query Fields() ([]*querypb.Field, error) // ID returns the connection id. ID() int64 // FetchNext returns the next row for a query FetchNext() ([]sqltypes.Value, error) }
Conn defines the behavior for the low level db connection
func Connect ¶
func Connect(params ConnParams) (Conn, error)
Connect returns a sqldb.Conn using the default connection creation function.
type ConnParams ¶
type ConnParams struct { Engine string `json:"engine"` Host string `json:"host"` Port int `json:"port"` Uname string `json:"uname"` Pass string `json:"pass"` DbName string `json:"dbname"` UnixSocket string `json:"unix_socket"` Charset string `json:"charset"` Flags uint64 `json:"flags"` // The following flags are only used for 'Change Master' command // for now (along with flags |= 2048 for CLIENT_SSL) SslCa string `json:"ssl_ca"` SslCaPath string `json:"ssl_ca_path"` SslCert string `json:"ssl_cert"` SslKey string `json:"ssl_key"` }
ConnParams contains all the parameters to use to connect to mysql
func (*ConnParams) EnableSSL ¶
func (cp *ConnParams) EnableSSL()
EnableSSL will set the right flag on the parameters.
func (*ConnParams) SslEnabled ¶
func (cp *ConnParams) SslEnabled() bool
SslEnabled returns if SSL is enabled.
type NewConnFunc ¶
type NewConnFunc func(params ConnParams) (Conn, error)
NewConnFunc is a factory method that creates a Conn instance using given ConnParams.