db

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(conn *sql.DB, query string) (sql.Result, error)

Exec executes a SQL statement that doesn't return rows.

func FormatTabular

func FormatTabular(headers []string, rows [][]string) string

FormatTabular formats query results as mysql-style tabular output. This allows reuse of the existing mask/format/parse infrastructure.

func Open

func Open(host string, port int, user, password, database string, allowOldPasswords bool) (*sql.DB, error)

Open opens a MySQL connection using go-sql-driver/mysql. If allowOldPasswords is true, the pre-4.1 old_password authentication is enabled. This should only be used for legacy MySQL 4.x connections.

func Ping

func Ping(conn *sql.DB) error

Ping tests the connection.

func Query

func Query(conn *sql.DB, query string) ([]string, [][]string, error)

Query executes a SQL query and returns headers and rows.

func SplitStatements added in v0.3.2

func SplitStatements(sqlText string) []string

SplitStatements splits a SQL string into individual statements by semicolons, respecting single-quoted, double-quoted, and backtick-quoted strings, as well as line comments (--) and block comments (/* */). Empty statements are skipped.

Types

This section is empty.

Jump to

Keyboard shortcuts

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