XU XUv0.8.8
中文

API

#github.com/xulang-org/packages/mysql

import: mysql #github.com/xulang-org/packages/mysql

counts: 6 fns, 0 methods, 2 types, 0 consts, 0 ifaces

MySQL/MariaDB database/sql driver. This driver is intentionally protocol-native: it does not require libmysqlclient, CGO, or a platform-specific runtime helper. It supports the text protocol, transactions, Prepare-shaped statements, and the mysql_native_password authentication plugin. `?` parameters are escaped by the driver before COM_QUERY is sent; placeholders inside SQL strings and comments are left untouched. TLS and caching_sha2_password are reserved for a later version and are rejected by the DSN parser. DSNs accepted by parse_dsn/open user:password@tcp(127.0.0.1:3306)/database?tls=false mysql://user:password@127.0.0.1:3306/database Defaults are host=127.0.0.1, port=3306, database=user.

github.com/xulang-org/packages · 0.1.1 · Install and use

driver

XuAPI
pub fn driver() driver.Driver

Purpose

MySQL/MariaDB database/sql driver. This driver is intentionally protocol-native: it does not require libmysqlclient, CGO, or a platform-specific runtime helper. It supports the text protocol, transactions, Prepare-shaped statements, and the mysql_native_password authentication plugin. `?` parameters are escaped by the driver before COM_QUERY is sent; placeholders inside SQL strings and comments are left untouched. TLS and caching_sha2_password are reserved for a later version and are rejected by the DSN parser. DSNs accepted by parse_dsn/open user:password@tcp(127.0.0.1:3306)/database?tls=false mysql://user:password@127.0.0.1:3306/database Defaults are host=127.0.0.1, port=3306, database=user.

Parameters

none

Returns

driver.Driver — a value of this type

open

XuAPI
pub fn open(dsn string) driver.Conn

Purpose

Open.

Parameters

dsn string
dsn (string)

Returns

driver.Conn — a value of this type

struct Config

XuAPI
pub struct Config {
    pub host string
    pub port int
    pub user string
    pub password string
    pub database string
    pub tls_mode string
}

Purpose

Public struct `Config`.

Parameters

host string
host
port int
port
user string
field (string)
password string
field (string)
database string
field (string)
tls_mode string
field (string)

new_config

XuAPI
pub fn new_config() Config

Purpose

Construct config.

Parameters

none

Returns

Config — a value of this type

parse_dsn

XuAPI
pub fn parse_dsn(dsn string) Config

Purpose

Parse as dsn. Throws on failure.

Parameters

dsn string
dsn (string)

Returns

Config — a value of this type

struct MysqlDriver

XuAPI
pub struct MysqlDriver {
    pub tag int
    pub dsn string
}

Purpose

Public struct `MysqlDriver`.

Parameters

tag int
field (int)
dsn string
field (string)

open_db

XuAPI
pub fn open_db(dsn string) sql.DB

Purpose

MySQL connection pool helpers. Configures reusable connections over database/sql connection pool.

Parameters

dsn string
dsn (string)

Returns

sql.DB — a value of this type

open_pool

XuAPI
pub fn open_pool(dsn string, max_open int, max_idle int) sql.DB

Purpose

Open pool.

Parameters

dsn string
dsn (string)
max_open int
max_open (int)
max_idle int
max_idle (int)

Returns

sql.DB — a value of this type