mysql

package
v0.0.0-...-2853686 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCHEMA_QUERY            = "DESCRIBE %s"                                                              // SCHEMA_QUERY is the SQL query used to describe a table schema.
	MYSQL_TABLES_LIST_QUERY = "SELECT table_name FROM information_schema.tables WHERE table_schema = %s" // MYSQL_TABLES_LIST_QUERY is the SQL query used to list all tables in a schema.
)

Variables

View Source
var DB_PASSWORD = "DB_PASSWORD"

DB_PASSWORD is the environment variable that stores the database password.

Functions

func NewMySQL

func NewMySQL(dbClient *sql.DB) (types.ISQL, error)

func NewMySQLWithConfig

func NewMySQLWithConfig(dbConfig *config.Config) (types.ISQL, error)

NewMySQLWithConfig creates a new MySQL client with the given configuration. It returns an error if the DB_PASSWORD environment variable is not set.

Types

type MySQL

type MySQL struct {
	Client *sql.DB // Client is the MySQL database client.
}

MySQL is a MySQL implementation of the ISQL interface.

func (*MySQL) Execute

func (m *MySQL) Execute(query string) ([]byte, error)

Execute a database query and return the result in JSON format

func (*MySQL) Schema

func (m *MySQL) Schema(table string) (types.Table, error)

This method will accept a table name as input and return the table schema (structure).

func (*MySQL) Tables

func (m *MySQL) Tables(databaseName string) ([]string, error)

Retrieve the names of tables in the specified database.

Jump to

Keyboard shortcuts

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