mysql

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQLAdapter

func NewMySQLAdapter(dsn string) (thing.DBAdapter, error)

NewMySQLAdapter creates a new MySQL adapter instance.

Types

type MySQLAdapter

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

MySQLAdapter implements the DBAdapter interface for MySQL.

func (*MySQLAdapter) BeginTx

func (a *MySQLAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (thing.Tx, error)

BeginTx starts a transaction.

func (*MySQLAdapter) Builder

func (a *MySQLAdapter) Builder() thing.SQLBuilder

func (*MySQLAdapter) Close

func (a *MySQLAdapter) Close() error

func (*MySQLAdapter) DB

func (a *MySQLAdapter) DB() *sql.DB

DB returns the underlying *sql.DB for advanced use cases.

func (*MySQLAdapter) DialectName

func (a *MySQLAdapter) DialectName() string

func (*MySQLAdapter) Exec

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

Exec executes a query that doesn't return rows (INSERT, UPDATE, DELETE). MySQL uses '?' placeholders.

func (*MySQLAdapter) Get

func (a *MySQLAdapter) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get retrieves a single row and scans it into the destination struct. Uses QueryContext and prepares scan destinations based on returned columns. MySQL uses '\' placeholders, which is the default for database/sql.

func (*MySQLAdapter) GetCount

func (a *MySQLAdapter) GetCount(ctx context.Context, tableName string, where string, args []interface{}) (int64, error)

GetCount executes a SELECT COUNT(*) query based on the provided parameters.

func (*MySQLAdapter) Select

func (a *MySQLAdapter) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select executes a query and scans the results into a slice. MySQL uses '?' placeholders.

type MySQLDialector

type MySQLDialector struct{}

MySQLDialector implements the sqlbuilder.Dialector interface for MySQL.

func (MySQLDialector) Placeholder

func (d MySQLDialector) Placeholder(_ int) string

func (MySQLDialector) Quote

func (d MySQLDialector) Quote(identifier string) string

type MySQLIntrospector

type MySQLIntrospector struct {
	DB *sql.DB
}

MySQLIntrospector implements schema.Introspector for MySQL.

func (*MySQLIntrospector) GetTableInfo

func (mi *MySQLIntrospector) GetTableInfo(ctx context.Context, tableName string) (*driversSchema.TableInfo, error)

GetTableInfo introspects the given table and returns its schema info (MySQL).

type MySQLTx

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

MySQLTx implements the Tx interface for MySQL.

func (*MySQLTx) Commit

func (tx *MySQLTx) Commit() error

Commit commits the transaction.

func (*MySQLTx) Exec

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

Exec executes a query within the transaction.

func (*MySQLTx) Get

func (tx *MySQLTx) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get executes a query within the transaction.

func (*MySQLTx) Rollback

func (tx *MySQLTx) Rollback() error

Rollback rolls back the transaction.

func (*MySQLTx) Select

func (tx *MySQLTx) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select executes a query within the transaction.

Jump to

Keyboard shortcuts

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