Documentation
¶
Index ¶
- Constants
- func IsPermissionError(err error) bool
- func NewQuerier[T any](conn *Db2Executor) querier.Querier[T]
- type Db2Conf
- type Db2Executor
- func (e *Db2Executor) Close() error
- func (e *Db2Executor) Exec(ctx context.Context, query string, args ...any) error
- func (e *Db2Executor) GetDb() *sqlx.DB
- func (e *Db2Executor) QueryRows(ctx context.Context, sql string, args ...interface{}) (*sqlx.Rows, error)
- func (e *Db2Executor) Select(ctx context.Context, dest any, query string, args ...any) error
Constants ¶
View Source
const ( AuthenticationServer = "SERVER" AuthenticationServerEncrypt = "SERVER_ENCRYPT" )
Authentication values.
Variables ¶
This section is empty.
Functions ¶
func IsPermissionError ¶
IsPermissionError reports whether err indicates the DWH credentials lack the privileges required for the attempted operation.
func NewQuerier ¶
func NewQuerier[T any](conn *Db2Executor) querier.Querier[T]
Types ¶
type Db2Conf ¶
type Db2Conf struct {
// Hostname is the Db2 server (HOSTNAME).
Hostname string
// Port is the TCP/IP port of the instance (PORT, the SVCENAME of the
// instance). Default: 50000, or 50001 when Security is SSL.
Port int
// Database is the database name or alias to connect to (DATABASE).
Database string
// User is the authorization ID (UID). Db2 authenticates it against the
// server's operating system or LDAP, not against a user stored in the
// database.
User string
// Password is the password of User (PWD).
Password string
// Security is "SSL" to connect over TLS (SECURITY=SSL); empty for a plain
// TCP/IP connection.
Security string
// SSLServerCertificateFile is the path to a PEM file holding the server's
// certificate or the CA that signed it (SSLServerCertificate). Requires
// Security SSL. Empty, with SSLServerCertificatePEM empty too, uses the
// system trust store.
SSLServerCertificateFile string
// SSLServerCertificatePEM is the same certificate as PEM text, for callers
// that hold it in memory and have no file to point at. Mutually exclusive
// with SSLServerCertificateFile.
SSLServerCertificatePEM string
// Authentication selects how the password is sent (AUTHENTICATION):
// "SERVER" (default) sends it in the clear, so pair it with SSL;
// "SERVER_ENCRYPT" encrypts user ID and password with a Diffie-Hellman
// key (DRDA security mechanism 9) and needs the instance's AUTHENTICATION
// to allow it.
Authentication string
}
Db2Conf configures a connection to IBM Db2 for Linux, UNIX and Windows.
The fields follow the keywords of a Db2 CLI/ODBC connection string, so a DBA can fill them from what they already use, e.g. `HOSTNAME=db2.example.com;PORT=50000;DATABASE=SAMPLE;UID=reader;PWD=...;SECURITY=SSL`. The driver speaks DRDA itself (github.com/go-db2/go-db2): no IBM client, clidriver or db2dsdriver.cfg is involved.
type Db2Executor ¶
type Db2Executor struct {
// contains filtered or unexported fields
}
func NewDb2Executor ¶
func NewDb2Executor(ctx context.Context, conf *Db2Conf) (*Db2Executor, error)
func (*Db2Executor) Close ¶
func (e *Db2Executor) Close() error
func (*Db2Executor) GetDb ¶
func (e *Db2Executor) GetDb() *sqlx.DB
Click to show internal directories.
Click to hide internal directories.