mysql

package module
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 12 Imported by: 44

Documentation

Overview

Package mysql implements gdb.Driver, which supports operations for database MySQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() gdb.Driver

New create and returns a driver that implements gdb.Driver, which supports operations for MySQL.

Types

type Driver added in v2.2.0

type Driver struct {
	*gdb.Core
}

Driver is the driver for mysql database.

func (*Driver) DoFilter added in v2.2.0

func (d *Driver) DoFilter(ctx context.Context, link gdb.Link, sql string, args []interface{}) (newSql string, newArgs []interface{}, err error)

DoFilter handles the sql before posts it to database.

func (*Driver) GetChars added in v2.2.0

func (d *Driver) GetChars() (charLeft string, charRight string)

GetChars returns the security char for this type of database.

func (*Driver) New added in v2.2.0

func (d *Driver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error)

New creates and returns a database object for mysql. It implements the interface of gdb.Driver for extra database driver installation.

func (*Driver) Open added in v2.2.0

func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error)

Open creates and returns an underlying sql.DB object for mysql. Note that it converts time.Time argument to local timezone in default.

func (*Driver) TableFields added in v2.2.0

func (d *Driver) TableFields(ctx context.Context, table string, schema ...string) (fields map[string]*gdb.TableField, err error)

TableFields retrieves and returns the fields' information of specified table of current schema.

The parameter `link` is optional, if given nil it automatically retrieves a raw sql connection as its link to proceed necessary sql query.

Note that it returns a map containing the field name and its corresponding fields. As a map is unsorted, the TableField struct has a "Index" field marks its sequence in the fields.

It's using cache feature to enhance the performance, which is never expired util the process restarts.

func (*Driver) Tables added in v2.2.0

func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string, err error)

Tables retrieves and returns the tables of current schema. It's mainly used in cli tool chain for automatically generating the models.

Jump to

Keyboard shortcuts

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