Skip to content


import ""


Package mysql wraps mysql driver as an adapter for REL.


// open mysql connection.
// note: `clientFoundRows=true` is required for update and delete to works correctly.
adapter, err := mysql.Open("root@(")
if err != nil {
defer adapter.Close()

// initialize REL's repo.
repo := rel.New(adapter)

func MustOpen

func MustOpen(dsn string) rel.Adapter
MustOpen mysql connection using dsn.

func New

func New(database *db.DB) rel.Adapter
New mysql adapter using existing connection. Existing connection needs to be created with clientFoundRows=true options for update and delete to works correctly.

func Open

func Open(dsn string) (rel.Adapter, error)
Open mysql connection using dsn.

type Quote

type Quote struct{}
Quote MySQL identifiers and literals.

func (Quote) ID

func (q Quote) ID(name string) string

func (Quote) Value

func (q Quote) Value(v interface{}) string

type ValueConvert

type ValueConvert struct{}
ValueConvert converts values to MySQL literals.

func (ValueConvert) ConvertValue

func (c ValueConvert) ConvertValue(v interface{}) (driver.Value, error)

Last update: 2022-06-25