const LEVEL_DEFAULT
pub const LEVEL_DEFAULT = 0Purpose
Default transaction isolation level determined by the driver or server.
#database/sqlUse database/sql with a concrete driver to manage a connection pool and execute SQL.
open takes a driver object and a driver-specific DSN; it opens connections lazily. This example uses SQLite in memory, checks operation errors and closes the pool explicitly.
Prerequisite: use the official packages checkout and build the SQLite native bridge for your target. Add this dependency to your project’s xu.xun, replacing the path with that checkout:
require:
"github.com/xulang-org/packages": file:/path/to/packages
See the MySQL quickstart for a server-backed driver and its DSN. MySQL service integration here: 待验 (not verified).
Save the complete program as main.xu and check it with xu check main.xu. One-step linking of native static libraries is supported on macOS arm64/x64, where you can use xu run main.xu; Linux requires object emission and a separate linker step. This example passed the SDK check; native execution is 待验 (not verified).
@main
#database/sql
sqlite #github.com/xulang-org/packages/sqlite
fn main() int {
$db := sql.open(sqlite.driver(), ":memory:")
db.exec("CREATE TABLE notes (body TEXT)") >>> (err) {
println(err.msg())
<< 1
}
result := db.exec("INSERT INTO notes VALUES ('hello')") >>> (err) {
println(err.msg())
<< 1
}
println(result.rows_affected())
db.close() >>> (err) {
println(err.msg())
<< 1
}
<< 0
}Expected output: 1 (the inserted row count).
These sources come from the official examples repository and can be copied or downloaded. Run them with a local Xu SDK in the complete project; network, database, and desktop examples require the corresponding services or assets.
18_database_mysql/main.xu@main
#database/sql
mysql #github.com/xulang-org/packages/mysql
#os
// MySQL/MariaDB:XU_MYSQL_DSN 可覆盖本地开发默认值。
// 驱动是普通 XU 包,通过 database/sql 接口使用,不依赖编译器内建。
fn main() int {
$dsn := os.getenv("XU_MYSQL_DSN")
if dsn.len == 0 {
dsn = "root:root@tcp(127.0.0.1:3306)/xu_demo?tls=false"
}
$db := sql.open(mysql.driver(), dsn)
db.ping() >>> (err) {
println("MySQL ping failed")
println(err.msg())
<< 1
}
db.exec("DROP TABLE IF EXISTS xu_people") >>> (err) {
println(err.msg())
<< 1
}
db.exec("CREATE TABLE xu_people (id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL, active BOOLEAN NOT NULL)") >>> (err) {
println(err.msg())
<< 1
}
first := db.exec(
"INSERT INTO xu_people (id, name, active) VALUES (?, ?, ?)",
1,
"Ada",
true
) >>> (err) {
println(err.msg())
<< 1
}
println("inserted=" + str(first.rows_affected()))
$insert_person := db.prepare(
"INSERT INTO xu_people (id, name, active) VALUES (?, ?, ?)"
) >>> (err) {
println(err.msg())
<< 1
}
insert_person.exec(2, "Lin", true) >>> (err) {
println(err.msg())
<< 1
}
insert_person.close()
$tx := db.begin() >>> (err) {
println(err.msg())
<< 1
}
tx.exec(
"INSERT INTO xu_people (id, name, active) VALUES (?, ?, ?)",
3,
"Grace",
true
) >>> (err) {
println(err.msg())
<< 1
}
tx.commit() >>> (err) {
println(err.msg())
<< 1
}
$rows := db.query("SELECT id, name FROM xu_people ORDER BY id") >>> (err) {
println(err.msg())
<< 1
}
while rows.next() {
values := rows.take() >>> (err) {
println(err.msg())
<< 1
}
id := values[0] as int
name := values[1] as string
println(str(id) + ": " + name)
}
if rows.err().len > 0 {
println(rows.err())
<< 1
}
rows.close()
row := db.query_row("SELECT name FROM xu_people WHERE id = ?", 2)
values := row.take() >>> (err) {
println(err.msg())
<< 1
}
println("selected=" + (values[0] as string))
db.close() >>> (err) {
println(err.msg())
<< 1
}
<< 0
}17_database_postgres/main.xu@main
#database/sql
postgres #github.com/xulang-org/packages/postgres
#os
// PostgreSQL:XU_POSTGRES_DSN 可覆盖本地开发默认值。
// 驱动是普通 XU 包,通过 database/sql 接口使用,不依赖编译器内建。
fn main() int {
$dsn := os.getenv("XU_POSTGRES_DSN")
if dsn.len == 0 {
dsn = "postgres://postgres:postgres@127.0.0.1:5432/xu_demo?sslmode=disable"
}
$db := sql.open(postgres.driver(), dsn)
db.ping() >>> (err) {
println("PostgreSQL ping failed")
println(err.msg())
<< 1
}
db.exec("DROP TABLE IF EXISTS xu_people") >>> (err) {
println(err.msg())
<< 1
}
db.exec("CREATE TABLE xu_people (id INTEGER PRIMARY KEY, name VARCHAR(100) NOT NULL, active BOOLEAN NOT NULL)") >>> (err) {
println(err.msg())
<< 1
}
first := db.exec(
"INSERT INTO xu_people (id, name, active) VALUES ($$1, $$2, $$3)",
1,
"Ada",
true
) >>> (err) {
println(err.msg())
<< 1
}
println("inserted=" + str(first.rows_affected()))
$insert_person := db.prepare(
"INSERT INTO xu_people (id, name, active) VALUES ($$1, $$2, $$3)"
)
insert_person.exec(2, "Lin", true) >>> (err) {
println(err.msg())
<< 1
}
insert_person.close()
$tx := db.begin() >>> (err) {
println(err.msg())
<< 1
}
tx.exec(
"INSERT INTO xu_people (id, name, active) VALUES ($$1, $$2, $$3)",
3,
"Grace",
true
) >>> (err) {
println(err.msg())
<< 1
}
tx.commit() >>> (err) {
println(err.msg())
<< 1
}
$rows := db.query("SELECT id, name FROM xu_people ORDER BY id") >>> (err) {
println(err.msg())
<< 1
}
while rows.next() {
values := rows.take() >>> (err) {
println(err.msg())
<< 1
}
id := values[0] as int
name := values[1] as string
println(str(id) + ": " + name)
}
if rows.err().len > 0 {
println(rows.err())
<< 1
}
rows.close()
$qrows := db.query("SELECT name FROM xu_people WHERE id = $$1", 2) >>> (err) {
println(err.msg())
<< 1
}
if qrows.next() {
vals := qrows.take() >>> (err) {
println(err.msg())
<< 1
}
println("selected=" + (vals[0] as string))
}
qrows.close()
db.close() >>> (err) {
println(err.msg())
<< 1
}
<< 0
}const LEVEL_DEFAULTpub const LEVEL_DEFAULT = 0Default transaction isolation level determined by the driver or server.
const LEVEL_READ_UNCOMMITTEDpub const LEVEL_READ_UNCOMMITTED = 1Read Uncommitted transaction isolation level permitting dirty reads.
const LEVEL_READ_COMMITTEDpub const LEVEL_READ_COMMITTED = 2Read Committed transaction isolation level preventing dirty reads.
const LEVEL_WRITE_COMMITTEDpub const LEVEL_WRITE_COMMITTED = 3Constant LEVEL_WRITE_COMMITTED, defining protocol or algorithm parameters.
const LEVEL_REPEATABLE_READpub const LEVEL_REPEATABLE_READ = 4Repeatable Read transaction isolation level preventing non-repeatable reads.
const LEVEL_SNAPSHOTpub const LEVEL_SNAPSHOT = 5Constant LEVEL_SNAPSHOT, defining protocol or algorithm parameters.
const LEVEL_SERIALIZABLEpub const LEVEL_SERIALIZABLE = 6Serializable transaction isolation level; support depends on the driver and database.
const LEVEL_LINEARIZABLEpub const LEVEL_LINEARIZABLE = 7Constant LEVEL_LINEARIZABLE, defining protocol or algorithm parameters.
struct TxOptionspub struct TxOptions {
pub isolation int
pub read_only bool
}Sql Configuration parameters and options set.
isolation intread_only boolstruct NamedArgpub struct NamedArg {
pub name string
pub value temp
}Structure encapsulating name, value.
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
}Concurrency-safe database connection pool managing idle connections and transactions.
drv driver.Driverdsn stringuse_connector intopener chan ConnSlotidle chan PooledConnst chan PoolStatestruct Connpub struct Conn {
pub closed int
pub slot chan PooledConn
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
}Structure encapsulating closed, slot, created_ns, idle_ns, idle.
closed intslot chan PooledConncreated_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
}In-flight transaction on dedicated database connection; must end with commit or rollback.
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
}Structure encapsulating last_insert_id, rows_affected.
last_insert_id introws_affected intstruct NullInt64pub struct NullInt64 {
pub v int
pub valid bool
}Structure encapsulating v, valid.
v intvalid boolstruct NullStringpub struct NullString {
pub s string
pub valid bool
}Structure encapsulating s, valid.
s stringvalid boolstruct NullBoolpub struct NullBool {
pub v bool
pub valid bool
}Structure encapsulating v, valid.
v boolvalid boolstruct NullFloat64pub struct NullFloat64 {
pub v f64
pub valid bool
}Structure encapsulating v, valid.
v f64valid boolstruct NullInt32pub struct NullInt32 {
pub v i32
pub valid bool
}Structure encapsulating v, valid.
v i32valid boolstruct NullBytepub struct NullByte {
pub v u8
pub valid bool
}Structure encapsulating v, valid.
v u8valid boolstruct NullTimepub struct NullTime {
pub t time.Time
pub valid bool
}Structure encapsulating t, valid.
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
}Structure encapsulating col, db_type, length, length_ok, nullable.
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
}SQL query result iterator cursor; iterate rows and close after use.
cols []stringcells []stringcur []stringncols inti intclosed interr stringhas intpooled intidle chan PooledConnpst chan PoolStatestruct Rowpub struct Row {
pub cells []string
pub err string
}Structure encapsulating cells, err.
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
}Structure encapsulating ds, qtext, closed, from_db, created_ns.
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) NamedArgConstruct a named SQL parameter (NamedArg).
name stringvalue tempNamedArg — a value of this type
openpub fn open(d driver.Driver, name string) DBCreate a database pool DB from a driver object and DSN; open connections lazily on first use.
d driver.Drivername stringdatabase pool instance DB
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; handle the error or propagate it to the caller.
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.DriverOperation on &DB: return the database driver instance implementing driver.Driver.
db &DBDB instance used by this call (borrow).driver.Driver — a value of this type
(&DB) pingpub fn (db &DB) ping() intSend a ping heartbeat request to verify connection liveness. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).int — a value of this type
(&DB) ping_contextpub fn (db &DB) ping_context(ctx &context.Context) intOperation on &DB: ping context. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.Contextint — a value of this type
(&DB) execpub fn (db &DB) exec(query string, args <-> temp) ResultExecute SQL statement or service command and return result. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).query stringargs <-> tempResult — a value of this type
(&DB) exec_contextpub fn (db &DB) exec_context(ctx &context.Context, query string, args <-> temp) ResultOperation on &DB: exec context. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&DB) querypub fn (db &DB) query(query string, args <-> temp) RowsExecute query on &DB. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).query stringargs <-> tempRows — a value of this type
(&DB) query_contextpub fn (db &DB) query_context(ctx &context.Context, query string, args <-> temp) RowsOperation on &DB: query context. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempRows — a value of this type
(&DB) query_rowpub fn (db &DB) query_row(query string, args <-> temp) RowOperation on &DB: query row.
db &DBDB instance used by this call (borrow).query stringargs <-> tempRow — a value of this type
(&DB) query_row_contextpub fn (db &DB) query_row_context(ctx &context.Context, query string, args <-> temp) RowOperation on &DB: query row context.
db &DBDB instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&DB) preparepub fn (db &DB) prepare(query string) StmtExecute prepare on &DB. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).query stringStmt — a value of this type
(&DB) prepare_contextpub fn (db &DB) prepare_context(ctx &context.Context, query string) StmtOperation on &DB: prepare context. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.Contextquery stringStmt — a value of this type
(&DB) beginpub fn (db &DB) begin() TxExecute begin on &DB. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).Tx — a value of this type
(&DB) begin_txpub fn (db &DB) begin_tx(ctx &context.Context, opts TxOptions) TxOperation on &DB: begin tx. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.Contextopts TxOptionsTx — a value of this type
(&DB) set_max_open_connspub fn (db &DB) set_max_open_conns(n int)Operation on &DB: set max open conns.
db &DBDB instance used by this call (borrow).n intThis call does not return a value.
(&DB) set_max_idle_connspub fn (db &DB) set_max_idle_conns(n int)Operation on &DB: set max idle conns.
db &DBDB instance used by this call (borrow).n intThis call does not return a value.
(&DB) set_conn_max_lifetimepub fn (db &DB) set_conn_max_lifetime(d int)Operation on &DB: set conn max lifetime.
db &DBDB instance used by this call (borrow).d intThis call does not return a value.
(&DB) set_conn_max_idle_timepub fn (db &DB) set_conn_max_idle_time(d int)Operation on &DB: set conn max idle time.
db &DBDB instance used by this call (borrow).d intThis call does not return a value.
(&DB) statspub fn (db &DB) stats() DBStatsExecute stats on &DB.
db &DBDB instance used by this call (borrow).DBStats — a value of this type
($&DB) closepub fn (db $&DB) close() intOperation on $&DB: close the resource. Throws on failure; handle the error or propagate it to the caller.
db $&DBDB instance used by this call (exclusive borrow).int — a value of this type
(&DB) connpub fn (db &DB) conn(ctx &context.Context) ConnOperation on &DB: connection. Throws on failure; handle the error or propagate it to the caller.
db &DBDB instance used by this call (borrow).ctx &context.ContextConn — a value of this type
(&Conn) ping_contextpub fn (c &Conn) ping_context(ctx &context.Context) intOperation on &Conn: ping context. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).ctx &context.Contextint — a value of this type
(&Conn) exec_contextpub fn (c &Conn) exec_context(ctx &context.Context, query string, args <-> temp) ResultOperation on &Conn: exec context. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&Conn) query_contextpub fn (c &Conn) query_context(ctx &context.Context, query string, args <-> temp) RowsOperation on &Conn: query context. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).ctx &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) RowOperation on &Conn: query row context.
c &ConnConn instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&Conn) rawpub fn (c &Conn) raw() driver.ConnExecute raw on &Conn. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).driver.Conn — a value of this type
(&Conn) prepare_contextpub fn (c &Conn) prepare_context(ctx &context.Context, query string) StmtOperation on &Conn: prepare context. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).ctx &context.Contextquery stringStmt — a value of this type
(&Conn) begin_txpub fn (c &Conn) begin_tx(ctx &context.Context, opts TxOptions) TxOperation on &Conn: begin tx. Throws on failure; handle the error or propagate it to the caller.
c &ConnConn instance used by this call (borrow).ctx &context.Contextopts TxOptionsTx — a value of this type
($&Conn) closepub fn (c $&Conn) close() intOperation on $&Conn: close the resource.
c $&ConnConn instance used by this call (exclusive borrow).int — a value of this type
(Result) last_insert_idpub fn (r Result) last_insert_id() intOperation on Result: last insert id.
r ResultResult instance used by this call (value receiver).int — a value of this type
(Result) rows_affectedpub fn (r Result) rows_affected() intOperation on Result: rows affected.
r ResultResult instance used by this call (value receiver).int — a value of this type
($&Rows) nextpub fn (r $&Rows) next() boolOperation on $&Rows: take the next item, or end according to this type.
r $&RowsRows instance used by this call (exclusive borrow).bool — true or false
($&Rows) takepub fn (r $&Rows) take() []tempExecute take on $&Rows. Throws on failure; handle the error or propagate it to the caller.
r $&RowsRows instance used by this call (exclusive borrow).[]temp — slice result
(&Rows) columnspub fn (r &Rows) columns() []stringExecute columns on &Rows.
r &RowsRows instance used by this call (borrow).[]string — slice result
($&Rows) closepub fn (r $&Rows) close()Operation on $&Rows: close the resource.
r $&RowsRows instance used by this call (exclusive borrow).This call does not return a value.
(&Rows) errpub fn (r &Rows) err() stringExecute err on &Rows.
r &RowsRows instance used by this call (borrow).string — result string
(ColumnType) namepub fn (ct ColumnType) name() stringExecute name on ColumnType.
ct ColumnTypeColumnType instance used by this call (value receiver).string — result string
(ColumnType) database_type_namepub fn (ct ColumnType) database_type_name() stringOperation on ColumnType: database type name.
ct ColumnTypeColumnType instance used by this call (value receiver).string — result string
(ColumnType) lengthpub fn (ct ColumnType) length() driver.NumberOperation on ColumnType: return the current length.
ct ColumnTypeColumnType instance used by this call (value receiver).driver.Number — a value of this type
(ColumnType) nullablepub fn (ct ColumnType) nullable() driver.NullInfoExecute nullable on ColumnType.
ct ColumnTypeColumnType instance used by this call (value receiver).driver.NullInfo — a value of this type
(ColumnType) decimal_sizepub fn (ct ColumnType) decimal_size() driver.DecimalSizeOperation on ColumnType: decimal size.
ct ColumnTypeColumnType instance used by this call (value receiver).driver.DecimalSize — a value of this type
(&Rows) column_typespub fn (r &Rows) column_types() []ColumnTypeOperation on &Rows: column types.
r &RowsRows instance used by this call (borrow).[]ColumnType — slice result
($&Rows) next_result_setpub fn (r $&Rows) next_result_set() boolOperation on $&Rows: next result set.
r $&RowsRows instance used by this call (exclusive borrow).bool — true or false
(&Row) errpub fn (r &Row) err() stringExecute err on &Row.
r &RowRow instance used by this call (borrow).string — result string
(&Row) takepub fn (r &Row) take() []tempExecute take on &Row. Throws on failure; handle the error or propagate it to the caller.
r &RowRow instance used by this call (borrow).[]temp — slice result
(&Tx) execpub fn (t &Tx) exec(query string, args <-> temp) ResultExecute SQL statement or service command and return result. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).query stringargs <-> tempResult — a value of this type
(&Tx) exec_contextpub fn (t &Tx) exec_context(ctx &context.Context, query string, args <-> temp) ResultOperation on &Tx: exec context. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempResult — a value of this type
(&Tx) querypub fn (t &Tx) query(query string, args <-> temp) RowsExecute query on &Tx. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).query stringargs <-> tempRows — a value of this type
(&Tx) query_contextpub fn (t &Tx) query_context(ctx &context.Context, query string, args <-> temp) RowsOperation on &Tx: query context. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempRows — a value of this type
(&Tx) query_rowpub fn (t &Tx) query_row(query string, args <-> temp) RowOperation on &Tx: query row.
t &TxTx instance used by this call (borrow).query stringargs <-> tempRow — a value of this type
(&Tx) query_row_contextpub fn (t &Tx) query_row_context(ctx &context.Context, query string, args <-> temp) RowOperation on &Tx: query row context.
t &TxTx instance used by this call (borrow).ctx &context.Contextquery stringargs <-> tempRow — a value of this type
(&Tx) preparepub fn (t &Tx) prepare(query string) StmtExecute prepare on &Tx. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).query stringStmt — a value of this type
(&Tx) prepare_contextpub fn (t &Tx) prepare_context(ctx &context.Context, query string) StmtOperation on &Tx: prepare context. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).ctx &context.Contextquery stringStmt — a value of this type
(&Tx) stmtpub fn (t &Tx) stmt(s &Stmt) StmtExecute stmt on &Tx. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).s &StmtStmt — a value of this type
(&Tx) stmt_contextpub fn (t &Tx) stmt_context(ctx &context.Context, s &Stmt) StmtOperation on &Tx: stmt context. Throws on failure; handle the error or propagate it to the caller.
t &TxTx instance used by this call (borrow).ctx &context.Contexts &StmtStmt — a value of this type
($&Tx) commitpub fn (t $&Tx) commit() intExecute commit on $&Tx. Throws on failure; handle the error or propagate it to the caller.
t $&TxTx instance used by this call (exclusive borrow).int — a value of this type
($&Tx) rollbackpub fn (t $&Tx) rollback() intExecute rollback on $&Tx. Throws on failure; handle the error or propagate it to the caller.
t $&TxTx instance used by this call (exclusive borrow).int — a value of this type
(&Stmt) execpub fn (s &Stmt) exec(args <-> temp) ResultExecute SQL statement or service command and return result. Throws on failure; handle the error or propagate it to the caller.
s &StmtStmt instance used by this call (borrow).args <-> tempResult — a value of this type
(&Stmt) exec_contextpub fn (s &Stmt) exec_context(ctx &context.Context, args <-> temp) ResultOperation on &Stmt: exec context. Throws on failure; handle the error or propagate it to the caller.
s &StmtStmt instance used by this call (borrow).ctx &context.Contextargs <-> tempResult — a value of this type
(&Stmt) querypub fn (s &Stmt) query(args <-> temp) RowsExecute query on &Stmt. Throws on failure; handle the error or propagate it to the caller.
s &StmtStmt instance used by this call (borrow).args <-> tempRows — a value of this type
(&Stmt) query_contextpub fn (s &Stmt) query_context(ctx &context.Context, args <-> temp) RowsOperation on &Stmt: query context. Throws on failure; handle the error or propagate it to the caller.
s &StmtStmt instance used by this call (borrow).ctx &context.Contextargs <-> tempRows — a value of this type
(&Stmt) query_rowpub fn (s &Stmt) query_row(args <-> temp) RowOperation on &Stmt: query row.
s &StmtStmt instance used by this call (borrow).args <-> tempRow — a value of this type
(&Stmt) query_row_contextpub fn (s &Stmt) query_row_context(ctx &context.Context, args <-> temp) RowOperation on &Stmt: query row context.
s &StmtStmt instance used by this call (borrow).ctx &context.Contextargs <-> tempRow — a value of this type
($&Stmt) closepub fn (s $&Stmt) close()Operation on $&Stmt: close the resource.
s $&StmtStmt instance used by this call (exclusive borrow).This call does not return a value.