mysql

package
v0.8.0 Latest Latest
Warning

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

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

Documentation

Overview

Package mysql provides the MySQL database driver implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQLDriver

func NewMySQLDriver() database.DatabaseDriver

NewMySQLDriver creates a new MySQL driver.

Types

type MySQLDriver

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

MySQLDriver implements the DatabaseDriver interface for MySQL/MariaDB.

func (*MySQLDriver) BeginTx

func (d *MySQLDriver) BeginTx(ctx context.Context) (database.Transaction, error)

BeginTx starts a new transaction.

func (*MySQLDriver) Close

func (d *MySQLDriver) Close() error

Close closes the database connection.

func (*MySQLDriver) Connect

func (d *MySQLDriver) Connect(ctx context.Context, dsn string) error

Connect establishes a connection to MySQL.

func (*MySQLDriver) CreateTable

func (d *MySQLDriver) CreateTable(schema database.TableSchema) (database.Query, error)

CreateTable generates and returns a CREATE TABLE query for MySQL.

func (*MySQLDriver) Delete

func (d *MySQLDriver) Delete(table string, where string, whereArgs ...interface{}) (database.Query, error)

Delete generates a DELETE query.

func (*MySQLDriver) DropTable

func (d *MySQLDriver) DropTable(tableName string) (database.Query, error)

DropTable generates a DROP TABLE query.

func (*MySQLDriver) Exec

func (d *MySQLDriver) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning rows.

func (*MySQLDriver) Insert

func (d *MySQLDriver) Insert(table string, data map[string]interface{}) (database.Query, error)

Insert generates an INSERT query (no RETURNING support in MySQL).

func (*MySQLDriver) MapType

func (d *MySQLDriver) MapType(schemaType string) string

MapType maps schema types to MySQL types.

func (*MySQLDriver) Ping

func (d *MySQLDriver) Ping(ctx context.Context) error

Ping checks if the connection is alive.

func (*MySQLDriver) Query

func (d *MySQLDriver) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a query that returns rows.

func (*MySQLDriver) QueryRow

func (d *MySQLDriver) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that returns at most one row.

func (*MySQLDriver) Select

func (d *MySQLDriver) Select(table string, columns []string, where string, whereArgs ...interface{}) (database.Query, error)

Select generates a SELECT query.

func (*MySQLDriver) SupportsArrays

func (d *MySQLDriver) SupportsArrays() bool

SupportsArrays returns false for MySQL.

func (*MySQLDriver) SupportsLastInsertId

func (d *MySQLDriver) SupportsLastInsertId() bool

SupportsLastInsertId returns true for MySQL.

func (*MySQLDriver) SupportsReturning

func (d *MySQLDriver) SupportsReturning() bool

SupportsReturning returns false for MySQL.

func (*MySQLDriver) TableExists

func (d *MySQLDriver) TableExists(tableName string) (bool, error)

TableExists checks if a table exists.

func (*MySQLDriver) Update

func (d *MySQLDriver) Update(table string, data map[string]interface{}, where string, whereArgs ...interface{}) (database.Query, error)

Update generates an UPDATE query.

Jump to

Keyboard shortcuts

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