mysql

package
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README


title: 'MySQL'

MySQL connector allows querying MySQL/MariaDB databases.

Config Schema

Field Type Required Description
type string yes constant: mysql
host string yes Database host address
database string yes Database name
user string yes Username
password string yes Password
port integer yes TCP port (default 3306)
tlsConfig string no TLS configuration name from MySQL server
conn_string string no Direct connection string (DSN format)

Config example:

type: mysql
host: localhost
database: mydb
user: root
password: secret
port: 3306
tlsConfig: ""       # Optional TLS configuration name from MySQL server 

Or as alternative with direct connection string:

type: mysql
conn_string: root:secret@tcp(localhost:3306)/mydb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host       string
	Database   string
	User       string
	Password   string
	Port       int
	TLSConfig  string
	ConnString string `yaml:"conn_string"`
	IsReadonly bool   `yaml:"is_readonly"`
}

func (Config) Doc

func (c Config) Doc() string

func (Config) ExtraPrompt added in v0.0.8

func (c Config) ExtraPrompt() []string

func (Config) MakeDSN

func (c Config) MakeDSN() (string, error)

func (Config) Readonly added in v0.2.1

func (c Config) Readonly() bool

func (Config) Type

func (c Config) Type() string

func (*Config) UnmarshalYAML added in v0.1.0

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface to allow for both direct connection string or full configuration objects in YAML

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func (Connector) Config added in v0.0.8

func (c Connector) Config() connectors.Config

func (Connector) Discovery

func (c Connector) Discovery(ctx context.Context, tablesList []string) ([]model.Table, error)

func (*Connector) GuessColumnType

func (c *Connector) GuessColumnType(sqlType string) model.ColumnType

GuessColumnType implements TypeGuesser interface for MySQL

func (*Connector) InferQuery

func (c *Connector) InferQuery(ctx context.Context, query string) ([]model.ColumnSchema, error)

InferQuery implements the Connector interface

func (*Connector) InferResultColumns

func (c *Connector) InferResultColumns(ctx context.Context, query string) ([]model.ColumnSchema, error)

InferResultColumns returns column information for the given query

func (Connector) LoadsColumns

func (c Connector) LoadsColumns(ctx context.Context, tableName string) ([]model.ColumnSchema, error)

func (Connector) Ping

func (c Connector) Ping(ctx context.Context) error

func (Connector) Query

func (c Connector) Query(ctx context.Context, endpoint model.Endpoint, params map[string]any) ([]map[string]any, error)

func (Connector) Sample

func (c Connector) Sample(ctx context.Context, table model.Table) ([]map[string]any, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL