db2

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db2 implements the Dialect of db2 database, supporting the corresponding database of db2 9.x+

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSource

func NewSource(bs *database.BaseSource) (s database.Source, err error)

NewSource generates a DB2 data source and will report an error if the configuration file is incorrect

func Quoted

func Quoted(s string) string

Quoted is the quoting function for DB2

Types

type Config

type Config struct {
	URL      string `json:"url"`      // Database URL, including database address and other database parameters
	Username string `json:"username"` // Username
	Password string `json:"password"` // Password
}

Config configuration ibm.com/docs/en/db2/11.1?topic=file-data-server-driver-configuration-keywords

func NewConfig

func NewConfig(conf *config.JSON) (c *Config, err error)

NewConfig creates a DB2 configuration and will report an error if the format does not meet the requirements

func (*Config) FormatDSN

func (c *Config) FormatDSN() (dsn string, err error)

FormatDSN generates data source connection information and will report an error if the URL is incorrect

type Dialect

type Dialect struct{}

Dialect is the dialect for the DB2 database

func (Dialect) Name

func (d Dialect) Name() string

Name is the registered name for the database dialect

func (Dialect) Source

func (d Dialect) Source(bs *database.BaseSource) (database.Source, error)

Source generates a DB2 data source

type Field

type Field struct {
	*database.BaseField
	database.BaseConfigSetter
}

Field represents a database field.

func NewField

func NewField(bf *database.BaseField) *Field

NewField creates a new field based on basic column attributes.

func (*Field) BindVar

func (f *Field) BindVar(_ int) string

BindVar represents an SQL placeholder used in SQL statements.

func (*Field) Quoted

func (f *Field) Quoted() string

Quoted is used for quoting in SQL statements.

func (*Field) Scanner

func (f *Field) Scanner() database.Scanner

Scanner is used for reading data.

func (*Field) Select

func (f *Field) Select() string

Select is the field used during queries for SQL SELECT statements.

func (*Field) Type

func (f *Field) Type() database.FieldType

Type represents the type of the field.

func (*Field) Valuer

func (f *Field) Valuer(c element.Column) database.Valuer

Valuer adopts GoValuer for processing data.

type FieldType

type FieldType struct {
	*database.BaseFieldType
	// contains filtered or unexported fields
}

FieldType represents the type of a field.

func NewFieldType

func NewFieldType(typ database.ColumnType) *FieldType

NewFieldType creates a new field type.

func (*FieldType) GoType

func (f *FieldType) GoType() database.GoType

GoType returns the Golang type used when processing numeric values.

func (*FieldType) IsSupported added in v0.1.8

func (f *FieldType) IsSupported() bool

IsSupported determines whether parsing is supported.

type Scanner

type Scanner struct {
	database.BaseScanner
	// contains filtered or unexported fields
}

Scanner is used for scanning data based on column types.

func NewScanner

func NewScanner(f *Field) *Scanner

NewScanner generates a scanner based on the column type.

func (*Scanner) Scan

func (s *Scanner) Scan(src interface{}) (err error)

Scan reads data based on the column type. INTEGER, BIGINT, and SMALLINT are treated as integers. DOUBLE, REAL, and DECIMAL are treated as high-precision real numbers. DATE, TIME, and TIMESTAMP are treated as time values. CHAR and VARCHAR are treated as strings. BLOB is treated as a byte stream. BOOLEAN is treated as a boolean value.

type Source

type Source struct {
	*database.BaseSource // Basic data source
	// contains filtered or unexported fields
}

Source is the DB2 data source

func (*Source) ConnectName

func (s *Source) ConnectName() string

ConnectName is the connection information for the data source from github.com/ibmdb/go_ibm_db

func (*Source) DriverName

func (s *Source) DriverName() string

DriverName is the driver name for github.com/ibmdb/go_ibm_db

func (*Source) Key

func (s *Source) Key() string

Key is the keyword for the data source, used for reuse by DBWrapper

func (*Source) Table

func (s *Source) Table(b *database.BaseTable) database.Table

Table generates a DB2 table

type Table

type Table struct {
	*database.BaseTable
	database.BaseConfigSetter
}

Table - A db2 table

func NewTable

func NewTable(b *database.BaseTable) *Table

NewTable - Creates a db2 table. Note that the schema parameter in BaseTable is empty at this point, instance is the database name, and name is the table name.

func (*Table) AddField

func (t *Table) AddField(baseField *database.BaseField)

AddField - Add a new column

func (*Table) ExecParam

func (t *Table) ExecParam(mode string, txOpts *sql.TxOptions) (database.Parameter, bool)

ExecParam - Acquire execution parameter

func (*Table) Quoted

func (t *Table) Quoted() string

Quoted - Refer to the table's full name

func (*Table) ShouldOneByOne

func (t *Table) ShouldOneByOne(err error) bool

ShouldOneByOne - Retry individually

func (*Table) ShouldRetry

func (t *Table) ShouldRetry(err error) bool

ShouldRetry - Retry

func (*Table) String

func (t *Table) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL