db2

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package db2 实现了db2的数据库方言Dialect,支持db2 10.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 生成db2数据源,在配置文件错误时会报错

func Quoted

func Quoted(s string) string

Quoted db2引用函数

Types

type Config

type Config struct {
	URL      string `json:"url"`      //数据库url,包含数据库地址,数据库其他参数
	Username string `json:"username"` //用户名
	Password string `json:"password"` //密码
}

Config 配置 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 创建db2配置,如果格式不符合要求,就会报错

func (*Config) FormatDSN

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

FormatDSN 生成数据源连接信息,url有错会报错

type Dialect

type Dialect struct{}

Dialect db2数据库方言

func (Dialect) Name

func (d Dialect) Name() string

Name 数据库方言的注册名

func (Dialect) Source

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

Source 生成db2数据源

type Field

type Field struct {
	*database.BaseField
}

Field 字段

func NewField

func NewField(bf *database.BaseField) *Field

NewField 通过基本列属性生成字段

func (*Field) BindVar

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

BindVar SQL占位符,用于SQL语句

func (*Field) Quoted

func (f *Field) Quoted() string

Quoted 引用,用于SQL语句

func (*Field) Scanner

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

Scanner 扫描器,用于读取数据

func (*Field) Select

func (f *Field) Select() string

Select 查询时字段,用于SQL查询语句

func (*Field) Type

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

Type 字段类型

func (*Field) Valuer

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

Valuer 赋值器,采用GoValuer处理数据

type FieldType

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

FieldType 字段类型

func NewFieldType

func NewFieldType(typ database.ColumnType) *FieldType

NewFieldType 创建新的字段类型

func (*FieldType) GoType

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

GoType 返回处理数值时的Golang类型

func (*FieldType) IsSupportted

func (f *FieldType) IsSupportted() bool

IsSupportted 是否支持解析

type Scanner

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

Scanner 扫描器

func NewScanner

func NewScanner(f *Field) *Scanner

NewScanner 根据列类型生成扫描器

func (*Scanner) Scan

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

Scan 根据列类型读取数据 "INTEGER", "BIGINT", "SMALLINT"作为整形处理 "DOUBLE", "REAL", "DECIMAL"作为高精度实数处理 "DATE", "TIME", "TIMESTAMP" 作为时间处理 "CHAR", "VARCHAR"作为字符串处理 "BLOB" 作为字节流处理 "BOOLEAN" 作为布尔值处理

type Source

type Source struct {
	*database.BaseSource //基础数据源
	// contains filtered or unexported fields
}

Source db2数据源

func (*Source) ConnectName

func (s *Source) ConnectName() string

ConnectName github.com/ibmdb/go_ibm_db的数据源连接信息

func (*Source) DriverName

func (s *Source) DriverName() string

DriverName github.com/ibmdb/go_ibm_db的驱动名

func (*Source) Key

func (s *Source) Key() string

Key 数据源的关键字,用于DBWrapper的复用

func (*Source) Table

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

Table 生成db2的表

type Table

type Table struct {
	*database.BaseTable
}

Table db2表

func NewTable

func NewTable(b *database.BaseTable) *Table

NewTable 创建db2表,注意此时BaseTable中的schema参数为空,instance为数据库名,而name是表明

func (*Table) AddField

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

AddField 新增列

func (*Table) ExecParam

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

ExecParam 获取执行参数

func (*Table) Quoted

func (t *Table) Quoted() string

Quoted 表引用全名

func (*Table) ShouldOneByOne

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

ShouldOneByOne 单个重试

func (*Table) ShouldRetry

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

ShouldRetry 重试

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