Documentation
¶
Index ¶
- func BuildDSN(opts MySQLOptions) (string, error)
- type MySQLClient
- func (c *MySQLClient) Connect(host string, port int, username, password string) (bool, error)
- func (c *MySQLClient) ConnectWithDSN(dsn string) (bool, error)
- func (c *MySQLClient) ExecuteQuery(host string, port int, username, password, query string) (*utils.SQLResult, error)
- func (c *MySQLClient) ExecuteQueryOnDB(host string, port int, username, password, dbname, query string) (*utils.SQLResult, error)
- func (c *MySQLClient) ExecuteQueryWithOpts(opts MySQLOptions, query string) (*utils.SQLResult, error)
- func (c *MySQLClient) FingerprintMySQL(host string, port int) (MySQLInfo, error)
- func (c *MySQLClient) IsMySQL(host string, port int) (bool, error)
- type MySQLInfo
- type MySQLOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildDSN ¶ added in v3.1.9
func BuildDSN(opts MySQLOptions) (string, error)
BuildDSN builds a MySQL data source name (DSN) from the given options.
Types ¶
type MySQLClient ¶
type MySQLClient struct{}
MySQLClient is a client for MySQL database.
Internally client uses go-sql-driver/mysql driver.
func (*MySQLClient) Connect ¶
Connect connects to MySQL database using given credentials.
If connection is successful, it returns true. If connection is unsuccessful, it returns false and error. The connection is closed after the function returns.
func (*MySQLClient) ConnectWithDSN ¶ added in v3.1.8
func (c *MySQLClient) ConnectWithDSN(dsn string) (bool, error)
ConnectWithDSN connects to MySQL database using given DSN. we override mysql dialer with fastdialer so it respects network policy
func (*MySQLClient) ExecuteQuery ¶
func (c *MySQLClient) ExecuteQuery(host string, port int, username, password, query string) (*utils.SQLResult, error)
ExecuteQuery connects to Mysql database using given credentials and executes a query on the db.
func (*MySQLClient) ExecuteQueryOnDB ¶ added in v3.1.9
func (c *MySQLClient) ExecuteQueryOnDB(host string, port int, username, password, dbname, query string) (*utils.SQLResult, error)
ExecuteQuery connects to Mysql database using given credentials and executes a query on the db.
func (*MySQLClient) ExecuteQueryWithOpts ¶ added in v3.1.9
func (c *MySQLClient) ExecuteQueryWithOpts(opts MySQLOptions, query string) (*utils.SQLResult, error)
func (*MySQLClient) FingerprintMySQL ¶ added in v3.1.9
func (c *MySQLClient) FingerprintMySQL(host string, port int) (MySQLInfo, error)
returns MySQLInfo when fingerpint is successful
type MySQLInfo ¶ added in v3.1.9
type MySQLInfo struct { Host string `json:"host,omitempty"` IP string `json:"ip"` Port int `json:"port"` Protocol string `json:"protocol"` TLS bool `json:"tls"` Transport string `json:"transport"` Version string `json:"version,omitempty"` Debug plugins.ServiceMySQL `json:"debug,omitempty"` Raw string `json:"metadata"` }
type MySQLOptions ¶ added in v3.1.9
type MySQLOptions struct { Host string // Host is the host name or IP address of the MySQL server. Port int // Port is the port number on which the MySQL server is listening. Protocol string // Protocol is the protocol used to connect to the MySQL server (ex: "tcp"). Username string // Username is the user name used to authenticate with the MySQL server. Password string // Password is the password used to authenticate with the MySQL server. DbName string // DbName is the name of the database to connect to on the MySQL server. RawQuery string // QueryStr is the query string to append to the DSN (ex: "?tls=skip-verify"). Timeout int // Timeout is the timeout in seconds for the connection to the MySQL server. }
MySQLOptions defines the data source name (DSN) options required to connect to a MySQL database. along with other options like Timeout etc