mysql

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

internal/mysql/client.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(cfg Config) (*Client, error)

func NewWithDB

func NewWithDB(db *sql.DB, cfg Config) (*Client, error)

NewWithDB constructs a Client from an existing *sql.DB. This is mainly useful for tests where we use a sqlmock.DB.

func (*Client) Close

func (c *Client) Close() error

func (*Client) DescribeTable

func (c *Client) DescribeTable(ctx context.Context, database, table string) ([]map[string]any, error)

func (*Client) ListDatabases

func (c *Client) ListDatabases(ctx context.Context) ([]string, error)

func (*Client) ListTables

func (c *Client) ListTables(ctx context.Context, database string) ([]string, error)

func (*Client) RunQuery

func (c *Client) RunQuery(ctx context.Context, sqlText string, maxRows int) ([]map[string]any, error)

RunQuery is intentionally “read oriented” – callers should enforce SELECT only.

type Config

type Config struct {
	DSN             string
	MaxRows         int
	QueryTimeoutS   int
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime time.Duration
	ConnMaxIdleTime time.Duration
	PingTimeout     time.Duration
}

Jump to

Keyboard shortcuts

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