API
#database/sql
Xu 0.8.8 API
import: #database/sql
counts: 9 函数, 63 方法, 18 类型, 8 常量, 0 方法集
数据库用户 API:open、连接池、Conn、事务、Stmt 与 Rows;具体驱动由外部 packages 提供。
const level_default
pub const level_default = 0
用途
`database/sql` user API over `database/sql/driver`. Open takes a Driver value, not a registry name: Xu has no mutable package global (same constraint as slog.SetDefault), so there is no `Register`. `OpenDB(Connector)` is `open_db`. DriverContext OpenConnector on Driver: iface forward-ref). `prepare_context` on driver.Conn is ConnPrepareContext. The pool matches `sql.DB`: lazy Open/OpenDB, idle list, get/put around Query/Exec/Ping. Query puts the conn back after the driver returns (v1 Rows is a snapshot; holds the conn until Rows.Close for streaming cursors). Tx holds a conn until Commit/Rollback. DB.Prepare does not pin (: release after prepare, re-prepare on the borrowed conn). Idle conns live on a channel because `[]driver.Conn` cannot move an element by runtime index. Open stores Driver+DSN and calls Driver.open ( `dsnConnector` is inlined: a second Connector impl next to the user's would collide sql.Conn is a pool handle (per-op get/put), not a checked-out exclusive box: struct@ cannot live in Conn and return to idle without a dup that aliases the unique box. Close only marks done. `raw` dups a checkout; drop that dup before the next pool op. SetMaxOpenConns(0)=unlimited; default max idle is 2. Lifetime/idle-time expire on get/put (no background cleaner). Idle reuse calls is_valid + reset_session ( Validator SessionResetter). Invalid conns are closed, not returned to idle. Idle queue cap is 64. DB Ping/Exec/Query retry `driver.ErrBadConn` up to 3 attempts ( `maxBadConnRetries` + alwaysNewConn). Args are snapshotted as cloneable wire strings because `temp` cannot be reused. Tx/Stmt do not retry (bound to one conn / one prepare). Exec/Query take `...temp` like (int/string/bool/f64/time.Time/[]u8/NamedArg (`temp` 拒借用); `Rows.next` + `take` returns a local `[]temp` of Values. Prepare is `Conn.Prepare` → `driver.Stmt`. Begin is `Conn.Begin` → `driver.Tx`. Tx holds a dup handle to the same conn (struct@ is move-only; dup shares the driver object). Isolation is the driver's rollback restores the snapshot taken at Begin. QueryRow is -shaped: it does not throw; `Row.take` surfaces ErrNoRows query errors ( `QueryRow` + `Scan`). sql.Rows owns a v1 snapshot from `driver.RowsResult` (not streaming `driver.Rows`); next/take walk flat cells. ColumnType* stubs return "" / ok=false at this layer. Context methods borrow `&context.Context`, check `context.err`, then forward ( `PingContext` &c). BeginTx with non-default isolation/read-only errors like when the driver has no ConnBeginTx. Driver.dup is Xu-only (struct@ is move-only). `Conn` is `sql.Conn` (dedicated pooled handle). Field `dc` is the driver conn so `conn(ctx)` can match `DB.Conn`. Exec/Query args become `[]driver.NamedValue` ( QueryerContext). NamedArg fills Name+Value; others are ordinal-only. Stmt.NumInput ≥ 0 must match argc. Connector.Connect borrows context. `raw` returns a dup of the dedicated driver conn. ColumnType.decimal_size is DecimalSize. 值为 `0`。
参数
无
const level_read_uncommitted
pub const level_read_uncommitted = 1
用途
公开常量 `level_read_uncommitted`。 值为 `1`
参数
无
const level_read_committed
pub const level_read_committed = 2
用途
公开常量 `level_read_committed`。 值为 `2`
参数
无
const level_write_committed
pub const level_write_committed = 3
用途
公开常量 `level_write_committed`。 值为 `3`
参数
无
const level_repeatable_read
pub const level_repeatable_read = 4
用途
公开常量 `level_repeatable_read`。 值为 `4`
参数
无
const level_snapshot
pub const level_snapshot = 5
用途
公开常量 `level_snapshot`。 值为 `5`
参数
无
const level_serializable
pub const level_serializable = 6
用途
公开常量 `level_serializable`。 值为 `6`
参数
无
const level_linearizable
pub const level_linearizable = 7
用途
公开常量 `level_linearizable`。 值为 `7`
参数
无
struct TxOptions
pub struct TxOptions {
pub isolation int
pub read_only bool
}
用途
公开结构体 `TxOptions`。
参数
isolation int- 字段(int)
read_only bool- 字段(bool)
struct NamedArg
pub struct NamedArg {
pub name string
pub value temp
}
用途
公开结构体 `NamedArg`。
参数
name string- 名字
value temp- 字段(temp)
struct DBStats
pub struct DBStats {
pub max_open_connections int
pub open_connections int
pub in_use int
pub idle int
pub wait_count int
pub max_idle_closed int
pub max_idle_time_closed int
pub max_lifetime_closed int
}
用途
公开结构体 `DBStats`。
参数
max_open_connections int- 字段(int)
open_connections int- 字段(int)
in_use int- 字段(int)
idle int- 字段(int)
wait_count int- 字段(int)
max_idle_closed int- 字段(int)
max_idle_time_closed int- 字段(int)
max_lifetime_closed int- 字段(int)
struct DB
pub struct DB {
pub drv driver.Driver
pub dsn string
pub use_connector int
pub opener chan ConnSlot
pub idle chan PooledConn
pub st chan PoolState
}
用途
公开结构体 `DB`。
参数
drv driver.Driver- 字段(driver.Driver)
dsn string- 字段(string)
use_connector int- 字段(int)
opener chan ConnSlot- 字段(通道;类型 chan ConnSlot)
idle chan PooledConn- 字段(通道;类型 chan PooledConn)
st chan PoolState- 字段(通道;类型 chan PoolState)
struct Conn
pub struct Conn {
pub closed int
pub created_ns int
pub idle_ns int
pub idle chan PooledConn
pub pst chan PoolState
pub drv driver.Driver
pub dsn string
pub use_connector int
pub opener chan ConnSlot
}
用途
公开结构体 `Conn`。
参数
closed int- 字段(int)
created_ns int- 字段(int)
idle_ns int- 字段(int)
idle chan PooledConn- 字段(通道;类型 chan PooledConn)
pst chan PoolState- 字段(通道;类型 chan PoolState)
drv driver.Driver- 字段(driver.Driver)
dsn string- 字段(string)
use_connector int- 字段(int)
opener chan ConnSlot- 字段(通道;类型 chan ConnSlot)
struct Tx
pub struct Tx {
pub slot chan PooledConn
pub dtx driver.Tx
pub done int
pub from_pool int
pub created_ns int
pub idle_ns int
pub idle chan PooledConn
pub pst chan PoolState
pub drv driver.Driver
pub dsn string
pub use_connector int
pub opener chan ConnSlot
}
用途
公开结构体 `Tx`。
参数
slot chan PooledConn- 字段(通道;类型 chan PooledConn)
dtx driver.Tx- 字段(driver.Tx)
done int- 字段(int)
from_pool int- 字段(int)
created_ns int- 字段(int)
idle_ns int- 字段(int)
idle chan PooledConn- 字段(通道;类型 chan PooledConn)
pst chan PoolState- 字段(通道;类型 chan PoolState)
drv driver.Driver- 字段(driver.Driver)
dsn string- 字段(string)
use_connector int- 字段(int)
opener chan ConnSlot- 字段(通道;类型 chan ConnSlot)
struct Result
pub struct Result {
pub last_insert_id int
pub rows_affected int
}
用途
公开结构体 `Result`。
参数
last_insert_id int- 字段(int)
rows_affected int- 字段(int)
struct NullInt64
pub struct NullInt64 {
pub v int
pub valid bool
}
用途
公开结构体 `NullInt64`。
参数
v int- 值
valid bool- 字段(bool)
struct NullString
pub struct NullString {
pub s string
pub valid bool
}
用途
公开结构体 `NullString`。
参数
s string- 源字符串
valid bool- 字段(bool)
struct NullBool
pub struct NullBool {
pub v bool
pub valid bool
}
用途
公开结构体 `NullBool`。
参数
v bool- 值
valid bool- 字段(bool)
struct NullFloat64
pub struct NullFloat64 {
pub v f64
pub valid bool
}
用途
公开结构体 `NullFloat64`。
参数
v f64- 值
valid bool- 字段(bool)
struct NullInt32
pub struct NullInt32 {
pub v i32
pub valid bool
}
用途
公开结构体 `NullInt32`。
参数
v i32- 值
valid bool- 字段(bool)
struct NullByte
pub struct NullByte {
pub v u8
pub valid bool
}
用途
公开结构体 `NullByte`。
参数
v u8- 值
valid bool- 字段(bool)
struct NullTime
pub struct NullTime {
pub t time.Time
pub valid bool
}
用途
公开结构体 `NullTime`。
参数
t time.Time- 字段(time.Time)
valid bool- 字段(bool)
struct ColumnType
pub struct ColumnType {
pub col string
pub db_type string
pub length int
pub length_ok bool
pub nullable bool
pub nullable_ok bool
pub precision int
pub scale int
pub precision_ok bool
}
用途
公开结构体 `ColumnType`。
参数
col string- 字段(string)
db_type string- 字段(string)
length int- 字段(int)
length_ok bool- 字段(bool)
nullable bool- 字段(bool)
nullable_ok bool- 字段(bool)
precision int- 字段(int)
scale int- 字段(int)
precision_ok bool- 字段(bool)
struct Rows
pub struct Rows {
pub cols []string
pub cells []string
pub cur []string
pub ncols int
pub i int
pub closed int
pub err string
pub has int
pub pooled int
pub idle chan PooledConn
pub pst chan PoolState
}
用途
公开结构体 `Rows`。
参数
cols []string- 字段([]string)
cells []string- 字段([]string)
cur []string- 字段([]string)
ncols int- 字段(int)
i int- 下标或整数
closed int- 字段(int)
err string- 错误
has int- 字段(int)
pooled int- 字段(int)
idle chan PooledConn- 字段(通道;类型 chan PooledConn)
pst chan PoolState- 字段(通道;类型 chan PoolState)
struct Row
pub struct Row {
pub cells []string
pub err string
}
用途
公开结构体 `Row`。
参数
cells []string- 字段([]string)
err string- 错误
struct Stmt
pub struct Stmt {
pub ds driver.Stmt
pub qtext string
pub closed int
pub from_db int
pub created_ns int
pub idle_ns int
pub idle chan PooledConn
pub pst chan PoolState
pub drv driver.Driver
pub dsn string
pub use_connector int
pub opener chan ConnSlot
}
用途
公开结构体 `Stmt`。
参数
ds driver.Stmt- 字段(driver.Stmt)
qtext string- 字段(string)
closed int- 字段(int)
from_db int- 字段(int)
created_ns int- 字段(int)
idle_ns int- 字段(int)
idle chan PooledConn- 字段(通道;类型 chan PooledConn)
pst chan PoolState- 字段(通道;类型 chan PoolState)
drv driver.Driver- 字段(driver.Driver)
dsn string- 字段(string)
use_connector int- 字段(int)
opener chan ConnSlot- 字段(通道;类型 chan ConnSlot)
named
pub fn named(name string, value temp) NamedArg
用途
named,返回 NamedArg。
参数
name string- 名字(string)
value temp- value(temp)
返回
NamedArg — 该类型的值
open
pub fn open(d driver.Driver, name string) DB
用途
打开。
参数
d driver.Driver- d(driver.Driver)
name string- 名字(string)
返回
DB — 该类型的值
open_db
pub fn open_db(c driver.Connector) DB
用途
打开db。
参数
c driver.Connector- 字节或字符码(driver.Connector)
返回
DB — 该类型的值
open_db_context
pub fn open_db_context(ctx &context.Context, c driver.Connector) DB
用途
打开db上下文。失败时 throw。
参数
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
c driver.Connector- 字节或字符码(driver.Connector)
返回
DB — 该类型的值
is_no_rows
pub fn is_no_rows(e errors.Error) bool
用途
判断是否 no rows。
参数
e errors.Error- e(errors.Error)
返回
bool — 是否成立
is_tx_done
pub fn is_tx_done(e errors.Error) bool
用途
判断是否 tx done。
参数
e errors.Error- e(errors.Error)
返回
bool — 是否成立
is_conn_done
pub fn is_conn_done(e errors.Error) bool
用途
判断是否 conn done。
参数
e errors.Error- e(errors.Error)
返回
bool — 是否成立
is_bad_conn
pub fn is_bad_conn(e errors.Error) bool
用途
判断是否 bad conn。
参数
e errors.Error- e(errors.Error)
返回
bool — 是否成立
isolation_name
pub fn isolation_name(level int) string
用途
isolation名称。
参数
level int- level(int)
返回
string — 结果字符串
(&DB) driver
pub fn (db &DB) driver() driver.Driver
用途
在 `&DB` 上调用 `driver`。
参数
db &DB- 接收者 &DB(借用)
返回
driver.Driver — 该类型的值
(&DB) ping
pub fn (db &DB) ping() int
用途
在 `&DB` 上调用 `ping`。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
返回
int — 该类型的值
(&DB) ping_context
pub fn (db &DB) ping_context(ctx &context.Context) int
用途
`&DB` 上的方法:ping上下文。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
返回
int — 该类型的值
(&DB) exec
pub fn (db &DB) exec(query string, args <-> temp) Result
用途
在 `&DB` 上调用 `exec`。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&DB) exec_context
pub fn (db &DB) exec_context(ctx &context.Context, query string, args <-> temp) Result
用途
`&DB` 上的方法:exec上下文。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&DB) query
pub fn (db &DB) query(query string, args <-> temp) Rows
用途
`&DB` 上的方法:查询串。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&DB) query_context
pub fn (db &DB) query_context(ctx &context.Context, query string, args <-> temp) Rows
用途
`&DB` 上的方法:查询串上下文。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&DB) query_row
pub fn (db &DB) query_row(query string, args <-> temp) Row
用途
`&DB` 上的方法:查询串row。
参数
db &DB- 接收者 &DB(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&DB) query_row_context
pub fn (db &DB) query_row_context(ctx &context.Context, query string, args <-> temp) Row
用途
`&DB` 上的方法:查询串row上下文。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&DB) prepare
pub fn (db &DB) prepare(query string) Stmt
用途
在 `&DB` 上调用 `prepare`。
参数
db &DB- 接收者 &DB(借用)
query string- query(string)
返回
Stmt — 该类型的值
(&DB) prepare_context
pub fn (db &DB) prepare_context(ctx &context.Context, query string) Stmt
用途
`&DB` 上的方法:prepare上下文。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
返回
Stmt — 该类型的值
(&DB) begin
pub fn (db &DB) begin() Tx
用途
在 `&DB` 上调用 `begin`。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
返回
Tx — 该类型的值
(&DB) begin_tx
pub fn (db &DB) begin_tx(ctx &context.Context, opts TxOptions) Tx
用途
`&DB` 上的方法:begintx。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
opts TxOptions- opts(TxOptions)
返回
Tx — 该类型的值
(&DB) set_max_open_conns
pub fn (db &DB) set_max_open_conns(n int)
用途
`&DB` 上的方法:设置 max open conns。
参数
db &DB- 接收者 &DB(借用)
n int- 数量、长度或上限(int)
(&DB) set_max_idle_conns
pub fn (db &DB) set_max_idle_conns(n int)
用途
`&DB` 上的方法:设置 max idle conns。
参数
db &DB- 接收者 &DB(借用)
n int- 数量、长度或上限(int)
(&DB) set_conn_max_lifetime
pub fn (db &DB) set_conn_max_lifetime(d int)
用途
`&DB` 上的方法:设置 conn max lifetime。
参数
db &DB- 接收者 &DB(借用)
d int- d(int)
(&DB) set_conn_max_idle_time
pub fn (db &DB) set_conn_max_idle_time(d int)
用途
`&DB` 上的方法:设置 conn max idle time。
参数
db &DB- 接收者 &DB(借用)
d int- d(int)
(&DB) stats
pub fn (db &DB) stats() DBStats
用途
在 `&DB` 上调用 `stats`。
参数
db &DB- 接收者 &DB(借用)
返回
DBStats — 该类型的值
(&mut DB) close
pub fn (db &mut DB) close() int
用途
`&mut DB` 上的方法:关闭资源。失败时 throw。
参数
db &mut DB- 接收者 &mut DB(可变借用)
返回
int — 该类型的值
(&DB) conn
pub fn (db &DB) conn(ctx &context.Context) Conn
用途
`&DB` 上的方法:连接。失败时 throw。
参数
db &DB- 接收者 &DB(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
返回
Conn — 该类型的值
(&Conn) ping_context
pub fn (c &Conn) ping_context(ctx &context.Context) int
用途
`&Conn` 上的方法:ping上下文。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
返回
int — 该类型的值
(&Conn) exec_context
pub fn (c &Conn) exec_context(ctx &context.Context, query string, args <-> temp) Result
用途
`&Conn` 上的方法:exec上下文。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&Conn) query_context
pub fn (c &Conn) query_context(ctx &context.Context, query string, args <-> temp) Rows
用途
`&Conn` 上的方法:查询串上下文。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&Conn) query_row_context
pub fn (c &Conn) query_row_context(ctx &context.Context, query string, args <-> temp) Row
用途
`&Conn` 上的方法:查询串row上下文。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&Conn) raw
pub fn (c &Conn) raw() driver.Conn
用途
在 `&Conn` 上调用 `raw`。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
返回
driver.Conn — 该类型的值
(&Conn) prepare_context
pub fn (c &Conn) prepare_context(ctx &context.Context, query string) Stmt
用途
`&Conn` 上的方法:prepare上下文。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
返回
Stmt — 该类型的值
(&Conn) begin_tx
pub fn (c &Conn) begin_tx(ctx &context.Context, opts TxOptions) Tx
用途
`&Conn` 上的方法:begintx。失败时 throw。
参数
c &Conn- 接收者 &Conn(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
opts TxOptions- opts(TxOptions)
返回
Tx — 该类型的值
(&mut Conn) close
pub fn (c &mut Conn) close() int
用途
`&mut Conn` 上的方法:关闭资源。
参数
c &mut Conn- 接收者 &mut Conn(可变借用)
返回
int — 该类型的值
(Result) last_insert_id
pub fn (r Result) last_insert_id() int
用途
`Result` 上的方法:last插入id。
参数
r Result- 接收者 Result(值接收者)
返回
int — 下标;未找到为 -1
(Result) rows_affected
pub fn (r Result) rows_affected() int
用途
`Result` 上的方法:rowsaffected。
参数
r Result- 接收者 Result(值接收者)
返回
int — 该类型的值
(&mut Rows) next
pub fn (r &mut Rows) next() bool
用途
`&mut Rows` 上的方法:取出下一项;没有则按本类型约定结束。
参数
r &mut Rows- 接收者 &mut Rows(可变借用)
返回
bool — 是否成立
(&mut Rows) take
pub fn (r &mut Rows) take() []temp
用途
在 `&mut Rows` 上调用 `take`。失败时 throw。
参数
r &mut Rows- 接收者 &mut Rows(可变借用)
返回
[]temp — 切片结果
(&Rows) columns
pub fn (r &Rows) columns() []string
用途
在 `&Rows` 上调用 `columns`。
参数
r &Rows- 接收者 &Rows(借用)
返回
[]string — 切片结果
(&mut Rows) close
pub fn (r &mut Rows) close()
用途
`&mut Rows` 上的方法:关闭资源。
参数
r &mut Rows- 接收者 &mut Rows(可变借用)
(&Rows) err
pub fn (r &Rows) err() string
用途
在 `&Rows` 上调用 `err`。
参数
r &Rows- 接收者 &Rows(借用)
返回
string — 结果字符串
(ColumnType) name
pub fn (ct ColumnType) name() string
用途
`ColumnType` 上的方法:名称。
参数
ct ColumnType- 接收者 ColumnType(值接收者)
返回
string — 结果字符串
(ColumnType) database_type_name
pub fn (ct ColumnType) database_type_name() string
用途
`ColumnType` 上的方法:databasetype名称。
参数
ct ColumnType- 接收者 ColumnType(值接收者)
返回
string — 结果字符串
(ColumnType) length
pub fn (ct ColumnType) length() driver.Number
用途
`ColumnType` 上的方法:返回当前长度。
参数
ct ColumnType- 接收者 ColumnType(值接收者)
返回
driver.Number — 该类型的值
(ColumnType) nullable
pub fn (ct ColumnType) nullable() driver.NullInfo
用途
在 `ColumnType` 上调用 `nullable`。
参数
ct ColumnType- 接收者 ColumnType(值接收者)
返回
driver.NullInfo — 该类型的值
(ColumnType) decimal_size
pub fn (ct ColumnType) decimal_size() driver.DecimalSize
用途
`ColumnType` 上的方法:decimal尺寸。
参数
ct ColumnType- 接收者 ColumnType(值接收者)
返回
driver.DecimalSize — 该类型的值
(&Rows) column_types
pub fn (r &Rows) column_types() []ColumnType
用途
`&Rows` 上的方法:columntypes。
参数
r &Rows- 接收者 &Rows(借用)
返回
[]ColumnType — 切片结果
(&mut Rows) next_result_set
pub fn (r &mut Rows) next_result_set() bool
用途
`&mut Rows` 上的方法:下一项结果set。
参数
r &mut Rows- 接收者 &mut Rows(可变借用)
返回
bool — 是否成立
(&Row) err
pub fn (r &Row) err() string
用途
在 `&Row` 上调用 `err`。
参数
r &Row- 接收者 &Row(借用)
返回
string — 结果字符串
(&Row) take
pub fn (r &Row) take() []temp
用途
在 `&Row` 上调用 `take`。失败时 throw。
参数
r &Row- 接收者 &Row(借用)
返回
[]temp — 切片结果
(&Tx) exec
pub fn (t &Tx) exec(query string, args <-> temp) Result
用途
在 `&Tx` 上调用 `exec`。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&Tx) exec_context
pub fn (t &Tx) exec_context(ctx &context.Context, query string, args <-> temp) Result
用途
`&Tx` 上的方法:exec上下文。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&Tx) query
pub fn (t &Tx) query(query string, args <-> temp) Rows
用途
`&Tx` 上的方法:查询串。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&Tx) query_context
pub fn (t &Tx) query_context(ctx &context.Context, query string, args <-> temp) Rows
用途
`&Tx` 上的方法:查询串上下文。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&Tx) query_row
pub fn (t &Tx) query_row(query string, args <-> temp) Row
用途
`&Tx` 上的方法:查询串row。
参数
t &Tx- 接收者 &Tx(借用)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&Tx) query_row_context
pub fn (t &Tx) query_row_context(ctx &context.Context, query string, args <-> temp) Row
用途
`&Tx` 上的方法:查询串row上下文。
参数
t &Tx- 接收者 &Tx(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&Tx) prepare
pub fn (t &Tx) prepare(query string) Stmt
用途
在 `&Tx` 上调用 `prepare`。
参数
t &Tx- 接收者 &Tx(借用)
query string- query(string)
返回
Stmt — 该类型的值
(&Tx) prepare_context
pub fn (t &Tx) prepare_context(ctx &context.Context, query string) Stmt
用途
`&Tx` 上的方法:prepare上下文。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
query string- query(string)
返回
Stmt — 该类型的值
(&Tx) stmt
pub fn (t &Tx) stmt(s &Stmt) Stmt
用途
在 `&Tx` 上调用 `stmt`。
参数
t &Tx- 接收者 &Tx(借用)
s &Stmt- 源字符串(借用,调用方仍持有;类型 &Stmt)
返回
Stmt — 该类型的值
(&Tx) stmt_context
pub fn (t &Tx) stmt_context(ctx &context.Context, s &Stmt) Stmt
用途
`&Tx` 上的方法:stmt上下文。失败时 throw。
参数
t &Tx- 接收者 &Tx(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
s &Stmt- 源字符串(借用,调用方仍持有;类型 &Stmt)
返回
Stmt — 该类型的值
(&mut Tx) commit
pub fn (t &mut Tx) commit() int
用途
在 `&mut Tx` 上调用 `commit`。失败时 throw。
参数
t &mut Tx- 接收者 &mut Tx(可变借用)
返回
int — 该类型的值
(&mut Tx) rollback
pub fn (t &mut Tx) rollback() int
用途
在 `&mut Tx` 上调用 `rollback`。失败时 throw。
参数
t &mut Tx- 接收者 &mut Tx(可变借用)
返回
int — 该类型的值
(&Stmt) exec
pub fn (s &Stmt) exec(args <-> temp) Result
用途
在 `&Stmt` 上调用 `exec`。失败时 throw。
参数
s &Stmt- 接收者 &Stmt(借用)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&Stmt) exec_context
pub fn (s &Stmt) exec_context(ctx &context.Context, args <-> temp) Result
用途
`&Stmt` 上的方法:exec上下文。失败时 throw。
参数
s &Stmt- 接收者 &Stmt(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Result — 该类型的值
(&Stmt) query
pub fn (s &Stmt) query(args <-> temp) Rows
用途
`&Stmt` 上的方法:查询串。失败时 throw。
参数
s &Stmt- 接收者 &Stmt(借用)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&Stmt) query_context
pub fn (s &Stmt) query_context(ctx &context.Context, args <-> temp) Rows
用途
`&Stmt` 上的方法:查询串上下文。失败时 throw。
参数
s &Stmt- 接收者 &Stmt(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Rows — 该类型的值
(&Stmt) query_row
pub fn (s &Stmt) query_row(args <-> temp) Row
用途
`&Stmt` 上的方法:查询串row。
参数
s &Stmt- 接收者 &Stmt(借用)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&Stmt) query_row_context
pub fn (s &Stmt) query_row_context(ctx &context.Context, args <-> temp) Row
用途
`&Stmt` 上的方法:查询串row上下文。
参数
s &Stmt- 接收者 &Stmt(借用)
ctx &context.Context- ctx(借用,调用方仍持有;类型 &context.Context)
args <-> temp- 可变参数,类型 temp,在函数体内是 []temp
返回
Row — 该类型的值
(&mut Stmt) close
pub fn (s &mut Stmt) close()
用途
`&mut Stmt` 上的方法:关闭资源。
参数
s &mut Stmt- 接收者 &mut Stmt(可变借用)