type NamedArg(struct)
A NamedArg is a named argument. NamedArg values may be used as
arguments to Query or Exec and bind to the corresponding named
parameter in the SQL statement.
For a more concise way to create NamedArg values, see
the Named function.
NamestringValueinterface{}
func Named(name string, value interface{}) NamedArg
type NullBool(struct)
NullBool represents a bool that may be null.
NullBool implements the Scanner interface so
it can be used as a scan destination, similar to NullString.
BoolboolValidbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type NullFloat64(struct)
NullFloat64 represents a float64 that may be null.
NullFloat64 implements the Scanner interface so
it can be used as a scan destination, similar to NullString.
Float64float64Validbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type NullInt32(struct)
NullInt32 represents an int32 that may be null.
NullInt32 implements the Scanner interface so
it can be used as a scan destination, similar to NullString.
Int32int32Validbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type NullInt64(struct)
NullInt64 represents an int64 that may be null.
NullInt64 implements the Scanner interface so
it can be used as a scan destination, similar to NullString.
Int64int64Validbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type NullString(struct)
NullString represents a string that may be null.
NullString implements the Scanner interface so
it can be used as a scan destination:
var s NullString
err := db.QueryRow("SELECT name FROM foo WHERE id=?", id).Scan(&s)
...
if s.Valid {
// use s.String
} else {
// NULL value
}
StringstringValidbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type NullTime(struct)
NullTime represents a time.Time that may be null.
NullTime implements the Scanner interface so
it can be used as a scan destination, similar to NullString.
Timetime.TimeValidbool
(*T) Scan(value interface{}) error
(T) Value() (driver.Value, error)
*T : Scanner
T : database/sql/driver.Valuer
type Out(struct)
Out may be used to retrieve OUTPUT value parameters from stored procedures.
Not all drivers and databases support OUTPUT value parameters.
Example usage:
var outArg string
_, err := db.ExecContext(ctx, "ProcName", sql.Named("Arg1", sql.Out{Dest: &outArg}))
Destinterface{}Inbool
type RawBytes([])
RawBytes is a byte slice that holds a reference to memory owned by
the database itself. After a Scan into a RawBytes, the slice is only
valid until the next call to Next, Scan, or Close.
func Drivers() []string
Drivers returns a sorted list of the names of the registered drivers.
var ErrConnDoneerror
ErrConnDone is returned by any operation that is performed on a connection
that has already been returned to the connection pool.
var ErrNoRowserror
ErrNoRows is returned by Scan when QueryRow doesn't return a
row. In such a case, QueryRow returns a placeholder *Row value that
defers this error until a Scan.
var ErrTxDoneerror
ErrTxDone is returned by any operation that is performed on a transaction
that has already been committed or rolled back.
const LevelDefaultIsolationLevel = 0
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelLinearizableIsolationLevel = 7
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelReadCommittedIsolationLevel = 2
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelReadUncommittedIsolationLevel = 1
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelRepeatableReadIsolationLevel = 4
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelSerializableIsolationLevel = 6
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelSnapshotIsolationLevel = 5
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
const LevelWriteCommittedIsolationLevel = 3
Various isolation levels that drivers may support in BeginTx.
If a driver does not support a given isolation level an error may be returned.
See https://en.wikipedia.org/wiki/Isolation_(database_systems)#Isolation_levels.
func Named(name string, value interface{}) NamedArg
Named provides a more concise way to create NamedArg values.
Example usage:
db.ExecContext(ctx, `
delete from Invoice
where
TimeCreated < @end
and TimeCreated >= @start;`,
sql.Named("start", startTime),
sql.Named("end", endTime),
)
func Open(driverName, dataSourceName string) (*DB, error)
Open opens a database specified by its database driver name and a
driver-specific data source name, usually consisting of at least a
database name and connection information.
Most users will open a database via a driver-specific connection
helper function that returns a *DB. No database drivers are included
in the Go standard library. See https://golang.org/s/sqldrivers for
a list of third-party drivers.
Open may just validate its arguments without creating a connection
to the database. To verify that the data source name is valid, call
Ping.
The returned DB is safe for concurrent use by multiple goroutines
and maintains its own pool of idle connections. Thus, the Open
function should be called just once. It is rarely necessary to
close a DB.
func OpenDB(c driver.Connector) *DB
OpenDB opens a database using a Connector, allowing drivers to
bypass a string based data source name.
Most users will open a database via a driver-specific connection
helper function that returns a *DB. No database drivers are included
in the Go standard library. See https://golang.org/s/sqldrivers for
a list of third-party drivers.
OpenDB may just validate its arguments without creating a connection
to the database. To verify that the data source name is valid, call
Ping.
The returned DB is safe for concurrent use by multiple goroutines
and maintains its own pool of idle connections. Thus, the OpenDB
function should be called just once. It is rarely necessary to
close a DB.
func Register(name string, driver driver.Driver)
Register makes a database driver available by the provided name.
If Register is called twice with the same name or if driver is nil,
it panics.
The pages are generated with Goldsv0.1.6. (GOOS=darwin GOARCH=amd64)
Golds is a Go 101 project and developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.