const level_default
pub const level_default = 0Purpose
Public constant `level_default`. Value `0`.
Parameters
none
API
#database/sqlDatabase API: open, pooling, Conn, transactions, Stmt, and Rows; concrete drivers come from external packages.
const level_defaultpub const level_default = 0Public constant `level_default`. Value `0`.
none
const level_read_uncommittedpub const level_read_uncommitted = 1Public constant `level_read_uncommitted`. Value `1`.
none
const level_read_committedpub const level_read_committed = 2Public constant `level_read_committed`. Value `2`.
none
const level_write_committedpub const level_write_committed = 3Public constant `level_write_committed`. Value `3`.
none
const level_repeatable_readpub const level_repeatable_read = 4Public constant `level_repeatable_read`. Value `4`.
none
const level_snapshotpub const level_snapshot = 5Public constant `level_snapshot`. Value `5`.
none
const level_serializablepub const level_serializable = 6Public constant `level_serializable`. Value `6`.
none
const level_linearizablepub const level_linearizable = 7Public constant `level_linearizable`. Value `7`.
none
struct TxOptionspub struct TxOptions {
pub isolation int
pub read_only bool
}Public struct `TxOptions`.
isolation intread_only boolstruct NamedArgpub struct NamedArg {
pub name string
pub value temp
}Public struct `NamedArg`.
name stringvalue tempstruct DBStatspub 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
}`sql.DBStats` (WaitDuration omitted: v1 does not accumulate wait ns).
max_open_connections intopen_connections intin_use intidle intwait_count intmax_idle_closed intmax_idle_time_closed intmax_lifetime_closed intstruct DBpub 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
}Public struct `DB`.
drv driver.Driverdsn stringuse_connector intopener chan ConnSlotidle chan PooledConnst chan PoolStatestruct Connpub 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
}Public struct `Conn`.
closed intcreated_ns intidle_ns intidle chan PooledConnpst chan PoolStatedrv driver.Driverdsn stringuse_connector intopener chan ConnSlotstruct Txpub 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
}Public struct `Tx`.
slot chan PooledConndtx driver.Txdone intfrom_pool intcreated_ns intidle_ns intidle chan PooledConnpst chan PoolStatedrv driver.Driverdsn stringuse_connector intopener chan ConnSlotstruct Resultpub struct Result {
pub last_insert_id int
pub rows_affected int
}Public struct `Result`.
last_insert_id introws_affected intstruct NullInt64pub struct NullInt64 {
pub v int
pub valid bool
}Public struct `NullInt64`.
v intvalid boolstruct NullStringpub struct NullString {
pub s string
pub valid bool
}Public struct `NullString`.
s stringvalid boolstruct NullBoolpub struct NullBool {
pub v bool
pub valid bool
}Public struct `NullBool`.
v boolvalid boolstruct NullFloat64pub struct NullFloat64 {
pub v f64
pub valid bool
}Public struct `NullFloat64`.
v f64valid boolstruct NullInt32pub struct NullInt32 {
pub v i32
pub valid bool
}Public struct `NullInt32`.
v i32valid boolstruct NullBytepub struct NullByte {
pub v u8
pub valid bool
}Public struct `NullByte`.
v u8valid boolstruct NullTimepub struct NullTime {
pub t time.Time
pub valid bool
}Public struct `NullTime`.
t time.Timevalid boolstruct ColumnTypepub 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
}Public struct `ColumnType`.
col stringdb_type stringlength intlength_ok boolnullable boolnullable_ok boolprecision intscale intprecision_ok boolstruct Rowspub 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
}Public struct `Rows`.
cols []stringcells []stringcur []stringncols inti intclosed interr stringhas intpooled intidle chan PooledConnpst chan PoolStatestruct Rowpub struct Row {
pub cells []string
pub err string
}Public struct `Row`.
cells []stringerr stringstruct Stmtpub 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
}Public struct `Stmt`.
ds driver.Stmtqtext stringclosed intfrom_db intcreated_ns intidle_ns intidle chan PooledConnpst chan PoolStatedrv driver.Driverdsn stringuse_connector intopener chan ConnSlotnamedpub fn named(name string, value temp) NamedArgnamed; returns NamedArg.
name stringvalue tempNamedArg — a value of this type
openpub fn open(d driver.Driver, name string) DBOpen.
d driver.Drivername stringDB — a value of this type
open_dbpub fn open_db(c driver.Connector) DBOpen db.
c driver.ConnectorDB — a value of this type
open_db_contextpub fn open_db_context(ctx &context.Context, c driver.Connector) DBOpen db context. Throws on failure.
ctx &context.Contextc driver.ConnectorDB — a value of this type
is_no_rowspub fn is_no_rows(e errors.Error) boolWhether it is no rows.
e errors.Errorbool — true or false
is_tx_donepub fn is_tx_done(e errors.Error) boolWhether it is tx done.
e errors.Errorbool — true or false
is_conn_donepub fn is_conn_done(e errors.Error) boolWhether it is conn done.
e errors.Errorbool — true or false
is_bad_connpub fn is_bad_conn(e errors.Error) boolWhether it is bad conn.
e errors.Errorbool — true or false
isolation_namepub fn isolation_name(level int) stringIsolation name.
level intstring — result string
(&DB) driverpub fn (db &DB) driver() driver.DriverCall `driver` on `&DB`.
db &DBdriver.Driver — a value of this type
(&DB) pingpub fn (db &DB) ping() intCall `ping` on `&DB`. Throws on failure.
db &DBint — a value of this type
(&DB) ping_contextpub fn (db &DB) ping_context(ctx &context.Context) intMethod on `&DB`: ping context. Throws on failure.
db &DBctx &context.Contextint — a value of this type
(&DB) execpub fn (db &DB) exec(query string, args <-> temp) ResultCall `exec` on `&DB`. Throws on failure.
db &DBquery stringargs <-> tempResult — a value of this type
(&DB) exec_contextpub fn (db &DB) exec_context(ctx &context.Context, query string, args <-> temp) ResultMethod on `&DB`: exec context. Throws on failure.
db &DBctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&DB) querypub fn (db &DB) query(query string, args <-> temp) RowsCall `query` on `&DB`. Throws on failure.
db &DBquery stringargs <-> tempRows — a value of this type
(&DB) query_contextpub fn (db &DB) query_context(ctx &context.Context, query string, args <-> temp) RowsMethod on `&DB`: query context.
db &DBctx &context.Contextquery stringargs <-> tempRows — a value of this type
(&DB) query_rowpub fn (db &DB) query_row(query string, args <-> temp) RowMethod on `&DB`: query row.
db &DBquery stringargs <-> tempRow — a value of this type
(&DB) query_row_contextpub fn (db &DB) query_row_context(ctx &context.Context, query string, args <-> temp) RowMethod on `&DB`: query row context.
db &DBctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&DB) preparepub fn (db &DB) prepare(query string) StmtCall `prepare` on `&DB`.
db &DBquery stringStmt — a value of this type
(&DB) prepare_contextpub fn (db &DB) prepare_context(ctx &context.Context, query string) StmtMethod on `&DB`: prepare context. Throws on failure.
db &DBctx &context.Contextquery stringStmt — a value of this type
(&DB) beginpub fn (db &DB) begin() TxCall `begin` on `&DB`. Throws on failure.
db &DBTx — a value of this type
(&DB) begin_txpub fn (db &DB) begin_tx(ctx &context.Context, opts TxOptions) TxMethod on `&DB`: begin tx. Throws on failure.
db &DBctx &context.Contextopts TxOptionsTx — a value of this type
(&DB) set_max_open_connspub fn (db &DB) set_max_open_conns(n int)Method on `&DB`: set max open conns.
db &DBn int(&DB) set_max_idle_connspub fn (db &DB) set_max_idle_conns(n int)Method on `&DB`: set max idle conns.
db &DBn int(&DB) set_conn_max_lifetimepub fn (db &DB) set_conn_max_lifetime(d int)Method on `&DB`: set conn max lifetime.
db &DBd int(&DB) set_conn_max_idle_timepub fn (db &DB) set_conn_max_idle_time(d int)Method on `&DB`: set conn max idle time.
db &DBd int(&DB) statspub fn (db &DB) stats() DBStatsCall `stats` on `&DB`.
db &DBDBStats — a value of this type
(&mut DB) closepub fn (db &mut DB) close() intMethod on `&mut DB`: close the resource. Throws on failure.
db &mut DBint — a value of this type
(&DB) connpub fn (db &DB) conn(ctx &context.Context) ConnMethod on `&DB`: connection. Throws on failure.
db &DBctx &context.ContextConn — a value of this type
(&Conn) ping_contextpub fn (c &Conn) ping_context(ctx &context.Context) intMethod on `&Conn`: ping context. Throws on failure.
c &Connctx &context.Contextint — a value of this type
(&Conn) exec_contextpub fn (c &Conn) exec_context(ctx &context.Context, query string, args <-> temp) ResultMethod on `&Conn`: exec context. Throws on failure.
c &Connctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&Conn) query_contextpub fn (c &Conn) query_context(ctx &context.Context, query string, args <-> temp) RowsMethod on `&Conn`: query context. Throws on failure.
c &Connctx &context.Contextquery stringargs <-> tempRows — a value of this type
(&Conn) query_row_contextpub fn (c &Conn) query_row_context(ctx &context.Context, query string, args <-> temp) RowMethod on `&Conn`: query row context.
c &Connctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&Conn) rawpub fn (c &Conn) raw() driver.ConnCall `raw` on `&Conn`. Throws on failure.
c &Conndriver.Conn — a value of this type
(&Conn) prepare_contextpub fn (c &Conn) prepare_context(ctx &context.Context, query string) StmtMethod on `&Conn`: prepare context. Throws on failure.
c &Connctx &context.Contextquery stringStmt — a value of this type
(&Conn) begin_txpub fn (c &Conn) begin_tx(ctx &context.Context, opts TxOptions) TxMethod on `&Conn`: begin tx. Throws on failure.
c &Connctx &context.Contextopts TxOptionsTx — a value of this type
(&mut Conn) closepub fn (c &mut Conn) close() intMethod on `&mut Conn`: close the resource.
c &mut Connint — a value of this type
(Result) last_insert_idpub fn (r Result) last_insert_id() intMethod on `Result`: last insert id.
r Resultint — index; -1 if missing
(Result) rows_affectedpub fn (r Result) rows_affected() intMethod on `Result`: rows affected.
r Resultint — a value of this type
(&mut Rows) nextpub fn (r &mut Rows) next() boolMethod on `&mut Rows`: take the next item, or end according to this type.
r &mut Rowsbool — true or false
(&mut Rows) takepub fn (r &mut Rows) take() []tempCall `take` on `&mut Rows`. Throws on failure.
r &mut Rows[]temp — slice result
(&Rows) columnspub fn (r &Rows) columns() []stringCall `columns` on `&Rows`.
r &Rows[]string — slice result
(&mut Rows) closepub fn (r &mut Rows) close()Method on `&mut Rows`: close the resource.
r &mut Rows(&Rows) errpub fn (r &Rows) err() stringCall `err` on `&Rows`.
r &Rowsstring — result string
(ColumnType) namepub fn (ct ColumnType) name() stringCall `name` on `ColumnType`.
ct ColumnTypestring — result string
(ColumnType) database_type_namepub fn (ct ColumnType) database_type_name() stringMethod on `ColumnType`: database type name.
ct ColumnTypestring — result string
(ColumnType) lengthpub fn (ct ColumnType) length() driver.NumberMethod on `ColumnType`: return the current length.
ct ColumnTypedriver.Number — a value of this type
(ColumnType) nullablepub fn (ct ColumnType) nullable() driver.NullInfoCall `nullable` on `ColumnType`.
ct ColumnTypedriver.NullInfo — a value of this type
(ColumnType) decimal_sizepub fn (ct ColumnType) decimal_size() driver.DecimalSizeMethod on `ColumnType`: decimal size.
ct ColumnTypedriver.DecimalSize — a value of this type
(&Rows) column_typespub fn (r &Rows) column_types() []ColumnTypeMethod on `&Rows`: column types.
r &Rows[]ColumnType — slice result
(&mut Rows) next_result_setpub fn (r &mut Rows) next_result_set() boolMethod on `&mut Rows`: next result set.
r &mut Rowsbool — true or false
(&Row) errpub fn (r &Row) err() stringCall `err` on `&Row`.
r &Rowstring — result string
(&Row) takepub fn (r &Row) take() []tempCall `take` on `&Row`. Throws on failure.
r &Row[]temp — slice result
(&Tx) execpub fn (t &Tx) exec(query string, args <-> temp) ResultCall `exec` on `&Tx`. Throws on failure.
t &Txquery stringargs <-> tempResult — a value of this type
(&Tx) exec_contextpub fn (t &Tx) exec_context(ctx &context.Context, query string, args <-> temp) ResultMethod on `&Tx`: exec context. Throws on failure.
t &Txctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&Tx) querypub fn (t &Tx) query(query string, args <-> temp) RowsCall `query` on `&Tx`. Throws on failure.
t &Txquery stringargs <-> tempRows — a value of this type
(&Tx) query_contextpub fn (t &Tx) query_context(ctx &context.Context, query string, args <-> temp) RowsMethod on `&Tx`: query context. Throws on failure.
t &Txctx &context.Contextquery stringargs <-> tempRows — a value of this type
(&Tx) query_rowpub fn (t &Tx) query_row(query string, args <-> temp) RowMethod on `&Tx`: query row.
t &Txquery stringargs <-> tempRow — a value of this type
(&Tx) query_row_contextpub fn (t &Tx) query_row_context(ctx &context.Context, query string, args <-> temp) RowMethod on `&Tx`: query row context.
t &Txctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&Tx) preparepub fn (t &Tx) prepare(query string) StmtCall `prepare` on `&Tx`.
t &Txquery stringStmt — a value of this type
(&Tx) prepare_contextpub fn (t &Tx) prepare_context(ctx &context.Context, query string) StmtMethod on `&Tx`: prepare context. Throws on failure.
t &Txctx &context.Contextquery stringStmt — a value of this type
(&Tx) stmtpub fn (t &Tx) stmt(s &Stmt) StmtCall `stmt` on `&Tx`.
t &Txs &StmtStmt — a value of this type
(&Tx) stmt_contextpub fn (t &Tx) stmt_context(ctx &context.Context, s &Stmt) StmtMethod on `&Tx`: stmt context. Throws on failure.
t &Txctx &context.Contexts &StmtStmt — a value of this type
(&mut Tx) commitpub fn (t &mut Tx) commit() intCall `commit` on `&mut Tx`. Throws on failure.
t &mut Txint — a value of this type
(&mut Tx) rollbackpub fn (t &mut Tx) rollback() intCall `rollback` on `&mut Tx`. Throws on failure.
t &mut Txint — a value of this type
(&Stmt) execpub fn (s &Stmt) exec(args <-> temp) ResultCall `exec` on `&Stmt`. Throws on failure.
s &Stmtargs <-> tempResult — a value of this type
(&Stmt) exec_contextpub fn (s &Stmt) exec_context(ctx &context.Context, args <-> temp) ResultMethod on `&Stmt`: exec context. Throws on failure.
s &Stmtctx &context.Contextargs <-> tempResult — a value of this type
(&Stmt) querypub fn (s &Stmt) query(args <-> temp) RowsCall `query` on `&Stmt`. Throws on failure.
s &Stmtargs <-> tempRows — a value of this type
(&Stmt) query_contextpub fn (s &Stmt) query_context(ctx &context.Context, args <-> temp) RowsMethod on `&Stmt`: query context. Throws on failure.
s &Stmtctx &context.Contextargs <-> tempRows — a value of this type
(&Stmt) query_rowpub fn (s &Stmt) query_row(args <-> temp) RowMethod on `&Stmt`: query row.
s &Stmtargs <-> tempRow — a value of this type
(&Stmt) query_row_contextpub fn (s &Stmt) query_row_context(ctx &context.Context, args <-> temp) RowMethod on `&Stmt`: query row context.
s &Stmtctx &context.Contextargs <-> tempRow — a value of this type
(&mut Stmt) closepub fn (s &mut Stmt) close()Method on `&mut Stmt`: close the resource.
s &mut Stmt