mysqlbe

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DQL
	SELECT  = "select"
	SHOW    = "show"
	DESC    = "desc"
	DESCRB  = "describe"
	WITH    = "with"
	EXPLAIN = "explain"
	TABLE   = "table"  // MySQL 8: TABLE t
	VALUES  = "values" // MySQL 8: VALUES ROW(...)

	// max rows fetched when browsing a table from the tree view
	FetchLimit = 200
)

Variables

This section is empty.

Functions

func GetDbName

func GetDbName() string

Types

type Backend

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

Backend adapts the mysql data-access layer to the db.Backend contract.

func Connect

func Connect(cfg Config) (*Backend, error)

Connect opens a mysql connection and pings it before returning.

func (*Backend) Close

func (b *Backend) Close() error

func (*Backend) ColumnIndexTypes

func (b *Backend) ColumnIndexTypes(namespace, table string) (map[string]string, error)

ColumnIndexTypes returns index type labels for indexed columns of namespace.table.

func (*Backend) ColumnsMeta

func (b *Backend) ColumnsMeta(namespace, table string) ([]db.ColumnMeta, error)

ColumnsMeta returns column metadata for namespace.table.

func (*Backend) CurrentNamespace

func (b *Backend) CurrentNamespace() string

CurrentNamespace reports the database this connection was opened against, so browsers can scope their listing to it (optional interface, not part of db.Backend).

func (*Backend) FetchTable

func (b *Backend) FetchTable(namespace, table string, limit int) (*data.Frame, error)

FetchTable loads up to limit rows of namespace.table.

func (*Backend) Kind

func (b *Backend) Kind() string

func (*Backend) Namespaces

func (b *Backend) Namespaces() ([]string, error)

Namespaces lists the databases of the server.

func (*Backend) PrimaryKeys

func (b *Backend) PrimaryKeys(namespace, table string) ([]string, error)

PrimaryKeys lists the primary-key column names of namespace.table.

func (*Backend) Run

func (b *Backend) Run(stmt string) (db.Result, error)

Run executes a statement, routing queries vs. mutations the same way the underlying data-access layer does. Query results come back as an all-string frame (NULL is not distinguishable from the empty string in the raw byte scan, so cells stay strings as-is).

func (*Backend) Tables

func (b *Backend) Tables(namespace string) ([]string, error)

Tables lists the tables of one database.

func (*Backend) Title

func (b *Backend) Title() string

type Config

type Config struct {
	UserName string
	Password string
	Host     string
	Port     string
	DbName   string
}

Config holds the connection parameters for a MySQL server.

func (Config) Dsn

func (c Config) Dsn() string

Dsn renders the config as a driver connection string: user:pass@tcp(host:port)/db?charset=utf8&parseTime=true

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}
var (
	DbClinet *DB
)

func GetDB

func GetDB() *DB

func NewDB

func NewDB(dsn string, dbName string) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ColumnIndexTypes

func (db *DB) ColumnIndexTypes(database, table string) (map[string]string, error)

ColumnIndexTypes returns a column→index-type map for database.table. Priority: PK > UNIQUE > INDEX. Columns not in any index are absent from the map.

func (*DB) ColumnsMeta

func (db *DB) ColumnsMeta(database, table string) ([]dbapi.ColumnMeta, error)

ColumnsMeta returns column metadata for database.table, in ordinal order. If database is empty the connection's current database is used.

func (*DB) FetchTableFields

func (db *DB) FetchTableFields(table string) ([]string, error)

func (*DB) FetchTableRecords

func (db *DB) FetchTableRecords(table string) ([][]string, error)

func (*DB) PrimaryKeys

func (db *DB) PrimaryKeys(database, table string) ([]string, error)

PrimaryKeys lists the primary-key column names of database.table, in key-ordinal order. If database is empty the connection's current database is used.

func (*DB) RawExec

func (db *DB) RawExec(query string) (sql.Result, error)

func (*DB) RawQuery

func (db *DB) RawQuery(query string) (fields []string, records [][]string, err error)

func (*DB) RawSqlCommand

func (db *DB) RawSqlCommand(query string) (rawCmdResult RawCommandResult, err error)

func (*DB) ShowCurrentDatabaseTables

func (db *DB) ShowCurrentDatabaseTables() ([]string, error)

func (*DB) ShowDatabaseTables

func (db *DB) ShowDatabaseTables(database string) ([]string, error)

func (*DB) ShowDatabases

func (db *DB) ShowDatabases() ([]string, error)

type RawCommandResult

type RawCommandResult struct {
	Fields  []string
	Records [][]string
	Result  sql.Result
	IsDQL   bool
}

Jump to

Keyboard shortcuts

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