package
0.0.0-20250312140307-836afd7c42ad
Repository: https://github.com/domonda/go-sqldb.git
Documentation: pkg.go.dev

# Functions

Conn returns a non nil sqldb.Connection from ctx or the global connection set with SetConn.
ConnDefault returns a non nil sqldb.Connection from ctx or the passed defaultConn.
ContextWithConn returns a new context with the passed sqldb.Connection added as value so it can be retrieved again using Conn(ctx).
CurrentTimestamp returns the SQL CURRENT_TIMESTAMP for the connection added to the context or else the default connection.
DebugNoTransaction executes nonTxFunc without a database transaction.
DebugPrintConn prints a line to stderr using the passed args and appending the transaction state of the connection and the current time of the database using `select now()` or an error if the time could not be queried.
Exec executes a query with optional args.
FprintTable prints a string table to an io.Writer padding the table with spaces and using the passed columnDelimiter between columns.
GetRow uses the passed pkValue+pkValues to query a table row and scan it into a struct of type S that must have tagged fields with primary key flags to identify the primary key column names for the passed pkValue+pkValues and a table name.
GetRowOrNil uses the passed pkValue+pkValues to query a table row and scan it into a struct of type S that must have tagged fields with primary key flags to identify the primary key column names for the passed pkValue+pkValues and a table name.
No description provided by the author
No description provided by the author
Insert a new row into table using the values.
InsertReturning inserts a new row into table using values and returns values from the inserted row listed in returning.
InsertStruct inserts a new row into table using the connection's StructFieldMapper to map struct fields to column names.
InsertStructs inserts a slice or array of structs as new rows into table using the connection's StructFieldMapper to map struct fields to column names.
InsertUnique inserts a new row into table using the passed values or does nothing if the onConflict statement applies.
InsertUniqueStruct inserts a new row into table using the connection's StructFieldMapper to map struct fields to column names.
IsolatedTransaction executes txFunc within a database transaction that is passed in to txFunc as tx Connection.
IsOtherThanErrNoRows returns true if the passed error is not nil and does not unwrap to, or is sql.ErrNoRows.
IsTransaction indicates if the connection from the context, or the default connection if the context has none, is a transaction.
No description provided by the author
No description provided by the author
OptionalTransaction executes txFunc within a database transaction if doTransaction is true.
PrintlnTable prints a string table to stdout padding the table with spaces and using '|' as delimiter between columns.
QueryRow queries a single row and returns a RowScanner for the results.
QueryRows queries multiple rows and returns a RowsScanner for the results.
QueryRowStruct queries a row and scans it as struct.
QueryRowStructOrNil queries a row and scans it as struct or returns nil in case of sql.ErrNoRows.
QueryRowStructReplaceErrNoRows queries a row and scans it as struct.
QueryStructSlice returns queried rows as slice of the generic type S which must be a struct or a pointer to a struct.
QueryValue queries a single value of type T.
QueryValueOr queries a single value of type T or returns the passed defaultValue in case of sql.ErrNoRows.
QueryValueReplaceErrNoRows queries a single value of type T.
ReplaceErrNoRows returns the passed replacement error if errors.Is(err, sql.ErrNoRows), else the passed err is returned unchanged.
SerializedTransaction executes txFunc "serially" within a database transaction that is passed in to txFunc via the context.
SetConn sets the global connection returned by Conn if there is no other connection in the context passed to Conn.
No description provided by the author
Transaction executes txFunc within a database transaction that is passed in to txFunc via the context.
TransactionOpts executes txFunc within a database transaction with sql.TxOptions that is passed in to txFunc via the context.
TransactionReadOnly executes txFunc within a read-only database transaction that is passed in to txFunc via the context.
TransactionSavepoint executes txFunc within a database transaction or uses savepoints for rollback.
TxOptionsString returns a string representing the passed TxOptions wich will be empty for the default options.
ValidateNotWithinTransaction returns sqldb.ErrWithinTransaction if the database connection from the context is a transaction.
ValidateWithinTransaction returns sqldb.ErrNotWithinTransaction if the database connection from the context is not a transaction.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Number of retries used for a SerializedTransaction before it fails.

# Structs

No description provided by the author