Documentation
¶
Overview ¶
Package mysql provides the MySQL database driver implementation.
Index ¶
- func NewMySQLDriver() database.DatabaseDriver
- type MySQLDriver
- func (d *MySQLDriver) BeginTx(ctx context.Context) (database.Transaction, error)
- func (d *MySQLDriver) Close() error
- func (d *MySQLDriver) Connect(ctx context.Context, dsn string) error
- func (d *MySQLDriver) CreateTable(schema database.TableSchema) (database.Query, error)
- func (d *MySQLDriver) Delete(table string, where string, whereArgs ...interface{}) (database.Query, error)
- func (d *MySQLDriver) DropTable(tableName string) (database.Query, error)
- func (d *MySQLDriver) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (d *MySQLDriver) Insert(table string, data map[string]interface{}) (database.Query, error)
- func (d *MySQLDriver) MapType(schemaType string) string
- func (d *MySQLDriver) Ping(ctx context.Context) error
- func (d *MySQLDriver) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (d *MySQLDriver) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (d *MySQLDriver) Select(table string, columns []string, where string, whereArgs ...interface{}) (database.Query, error)
- func (d *MySQLDriver) SupportsArrays() bool
- func (d *MySQLDriver) SupportsLastInsertId() bool
- func (d *MySQLDriver) SupportsReturning() bool
- func (d *MySQLDriver) TableExists(tableName string) (bool, error)
- func (d *MySQLDriver) Update(table string, data map[string]interface{}, where string, ...) (database.Query, error)
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) 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) 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.