mysql

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mysql 实现了 gdb.Driver 接口,该接口支持对 MySQL 数据库的相关操作。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() db类.Driver

New 创建并返回一个实现 gdb.Driver 接口的驱动程序,该驱动程序支持针对 MySQL 的操作。

Types

type Driver

type Driver struct {
	*db类.Core
}

Driver 是 MySQL 数据库的驱动程序。

func (*Driver) New

func (d *Driver) New(core *db类.Core, node *db类.X配置项) (db类.DB, error)

New 创建并返回一个用于 mysql 的数据库对象。 它实现了 gdb.Driver 接口,以便进行额外的数据库驱动安装。

func (*Driver) X取表名称数组

func (d *Driver) X取表名称数组(上下文 context.Context, schema ...string) (表名称数组 []string, 错误 error)

Tables 获取并返回当前模式的表。 它主要用于cli工具链中,用于自动生成模型。

func (*Driver) X取表字段信息Map

func (d *Driver) X取表字段信息Map(上下文 context.Context, 表名称 string, schema ...string) (字段信息Map map[string]*db类.TableField, err error)

TableFields 获取并返回当前模式下指定表的字段信息。

参数`link`是可选的,如果给定为nil,它会自动获取一个原始sql连接作为链接执行必要的sql查询。

注意,它返回一个包含字段名及其对应字段信息的map。由于map是无序的,TableField结构体中有一个"Index"字段标记其在所有字段中的顺序。

为了提高性能,该方法使用了缓存功能,缓存有效期直到进程重启才会失效。

func (*Driver) X底层DoFilter

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

DoFilter 在将 SQL 发送给数据库之前处理 SQL。

func (*Driver) X底层Open

func (d *Driver) X底层Open(配置对象 *db类.X配置项) (db *sql.DB, err error)

Open 创建并返回一个用于 mysql 的底层 sql.DB 对象。 注意,它默认会将 time.Time 类型参数转换为本地时区。

func (*Driver) X底层取数据库安全字符

func (d *Driver) X底层取数据库安全字符() (左字符 string, 右字符 string)

GetChars 返回此类型数据库的安全字符。

Jump to

Keyboard shortcuts

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