Documentation
¶
Overview ¶
MySQL integration.
Index ¶
- Constants
- func AddMySQLBootstrapCallback(cbk MySQLBootstrapCallback)
- func GetManaged(name string) *gorm.DB
- func GetMySQL() *gorm.DB
- func InitMySQL(rail miso.Rail, p MySQLConnParam) error
- func InitMySQLFromProp(rail miso.Rail) error
- func IsMySQLInitialized() bool
- func LogShowGrants(rail miso.Rail, db *gorm.DB)
- func NewMySQLConn(rail miso.Rail, p MySQLConnParam) (*gorm.DB, error)
- func ShowGrants(rail miso.Rail, db *gorm.DB) ([]string, error)
- type MySQLBootstrapCallback
- type MySQLConnParam
Constants ¶
View Source
const ( // misoconfig-prop: enable MySQL client | false PropMySQLEnabled = "mysql.enabled" // misoconfig-prop: username | root PropMySQLUser = "mysql.user" // misoconfig-prop: password PropMySQLPassword = "mysql.password" // misoconfig-prop: database PropMySQLSchema = "mysql.database" // misoconfig-prop: host | localhost PropMySQLHost = "mysql.host" // misoconfig-prop: port | 3306 PropMySQLPort = "mysql.port" // misoconfig-prop: log sql statements | false PropMySQLLogSQL = "mysql.log-sql" // misoconfig-prop: enable prepared statement | true PropMySQLPrepareStmt = "mysql.prepare-statement" // misoconfig-prop: disabled nested transaction | true PropMySQLDisableNestedTx = "mysql.disable-nested-transaction" // misoconfig-prop: connection parameters (slices of strings) (see [go-sql-driver/mysql](https://github.com/go-sql-driver/mysql?tab=readme-ov-file#dsn-data-source-name)) | `[]string{"charset=utf8mb4", "parseTime=true", "loc=Local", "readTimeout=30s", "writeTimeout=30s", "timeout=3s", "collation=utf8mb4_general_ci", "interpolateParams=false"}` PropMySQLConnParam = "mysql.connection.parameters" // misoconfig-prop: connection lifetime in minutes (hikari recommends 1800000, so we do the same thing) | 30 PropMySQLConnLifetime = "mysql.connection.lifetime" // misoconfig-prop: max number of open connections | 10 PropMySQLMaxOpenConns = "mysql.connection.open.max" // misoconfig-prop: max number of idle connections | 10 PropMySQLMaxIdleConns = "mysql.connection.idle.max" // misoconfig-prop: managed connection username | root // misoconfig-doc-only PropMySQLManagedUser = "mysql.managed.${name}.user" // misoconfig-prop: managed connection password // misoconfig-doc-only PropMySQLManagedPassword = "mysql.managed.${name}.password" // misoconfig-prop: managed connection database // misoconfig-doc-only PropMySQLManagedSchema = "mysql.managed.${name}.database" // misoconfig-prop: managed connection host | localhost // misoconfig-doc-only PropMySQLManagedHost = "mysql.managed.${name}.host" // misoconfig-prop: managed connection port | 3306 // misoconfig-doc-only PropMySQLManagedPort = "mysql.managed.${name}.port" // misoconfig-prop: managed connection enable prepared statement | true // misoconfig-doc-only PropMySQLManagedPrepareStmt = "mysql.managed.${name}.prepare-statement" )
misoconfig-section: MySQL Configuration
Variables ¶
This section is empty.
Functions ¶
func AddMySQLBootstrapCallback ¶
func AddMySQLBootstrapCallback(cbk MySQLBootstrapCallback)
func GetManaged ¶ added in v0.2.13
Get Managed MySQL Connection.
func InitMySQL ¶
func InitMySQL(rail miso.Rail, p MySQLConnParam) error
Init Handle to the database
If mysql client has been initialized, current func call will be ignored.
func InitMySQLFromProp ¶
Init connection to mysql
If mysql client has been initialized, current func call will be ignored.
This func looks for following props:
"mysql.user" "mysql.password" "mysql.database" "mysql.host" "mysql.port" "mysql.connection.parameters"
func NewMySQLConn ¶
Create new MySQL connection
Types ¶
Click to show internal directories.
Click to hide internal directories.