# README
MySQL
- 在入口,比如 main.go 里面隐式导入mysql包路径
import _ "github.com/fankane/go-utils/plugin/database/mysql"
- 在运行文件根目录下的 system_plugin.yaml 文件(没有则新建一个)里面添加如下内容
plugins:
database: # 插件类型:
mysql: # 插件名
default: # MySQL连接名称:default,可以是其他名字
host: 127.0.0.1
port: 3306
user: root
pwd: 123456
db_name: demo
params: parseTime=true
conn_max_life_time_sec: 600 # 连接最大存活时间, 不填连接建立后一直不会关闭 单位:秒
conn_max_idle_time_sec: 600 # 空闲连接最大存活时间, 单位:秒
max_open_conn: 10 # 最大连接数, 不填默认无限制
max_idle_conn: 2 # 最大空闲连接数,不填,mysql1.7.1 默认为2
mysql2: #
host: 127.0.0.1
port: 3306
user: root
pwd: 123456
db_name: demo
params: parseTime=true
conn_max_life_time_sec: 600 # 连接最大存活时间, 不填连接建立后一直不会关闭 单位:秒
conn_max_idle_time_sec: 600 # 空闲连接最大存活时间, 单位:秒
max_open_conn: 10 # 最大连接数, 不填默认无限制
max_idle_conn: 2 # 最大空闲连接数,不填,mysql1.7.1 默认为2
- 在需要使用的地方,直接使用
使用默认 default 的log, 直接如下
mysql.DB.Query()
使用指定MySQL连接, 如下:
mysql.GetDB("mysql2").Query()
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
TableColumn SHOW FULL COLUMNS FROM db_name.table_name 返回结果.
TableStatus show TABLE STATUS; 返回结果.