oracle

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package oracle 实现了oracle的数据库方言Dialect,支持oracle 10.5+ 对应数据库

Index

Constants

View Source
const WriteModeInsert = "insert"

WriteModeInsert intert into 写入方式

Variables

This section is empty.

Functions

func NewSource

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

NewSource 生成oracle数据源,在配置文件错误时会报错

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 配置

func NewConfig

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

NewConfig 创建oracle配置,如果格式不符合要求,就会报错

func (*Config) FetchConnectionParams

func (c *Config) FetchConnectionParams() (con godror.ConnectionParams, err error)

FetchConnectionParams 获取oracle连接参数,url有错会报错

type Dialect

type Dialect struct{}

Dialect oracle数据库方言

func (Dialect) Name

func (d Dialect) Name() string

Name 数据库方言的注册名

func (Dialect) Source

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

Source 生成oracle数据源

type Field

type Field struct {
	*database.BaseField
}

Field 字段

func NewField

func NewField(bf *database.BaseField) *Field

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

func (*Field) BindVar

func (f *Field) BindVar(i 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) IsSupportted

func (f *FieldType) IsSupportted() bool

IsSupportted 是否支持解析

type InsertParam

type InsertParam struct {
	*database.BaseParam
}

InsertParam Insert into 参数

func NewInsertParam

func NewInsertParam(t database.Table, txOpts *sql.TxOptions) *InsertParam

NewInsertParam 通过表table和事务参数txOpts插入参数

func (*InsertParam) Agrs

func (ip *InsertParam) Agrs(records []element.Record) (valuers []interface{}, err error)

Agrs 通过多条记录 records生成批量insert into参数

func (*InsertParam) Query

func (ip *InsertParam) Query(_ []element.Record) (query string, err error)

Query 通过多条记录 records生成批量insert into插入sql语句

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 根据列类型读取数据 "BOOLEAN" 做为bool类型处理 "BINARY_INTEGER" 做为bigint类型处理 "NUMBER", "FLOAT", "DOUBLE" 做为decimal类型处理 "TIMESTAMP", "TIMESTAMP WITH TIME ZONE", "TIMESTAMP WITH LOCAL TIME ZONE", "DATE"做为time类型处理 "CLOB", "NCLOB", "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR"做为string类型处理 "BLOB", "RAW", "LONG RAW", "LONG" 做为bytes类型处理

type Source

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

Source oracle数据源

func (*Source) ConnectName

func (s *Source) ConnectName() string

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

func (*Source) DriverName

func (s *Source) DriverName() string

DriverName github.com/godror/godror的驱动名

func (*Source) Key

func (s *Source) Key() string

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

func (*Source) Table

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

Table 生成oracle的表

type Table

type Table struct {
	*database.BaseTable
}

Table oracle表

func NewTable

func NewTable(b *database.BaseTable) *Table

NewTable 创建oracle表,注意此时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 获取执行参数,其中replace into的参数方式以及被注册

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

type Valuer

type Valuer struct {
	// contains filtered or unexported fields
}

Valuer 赋值器

func NewValuer

func NewValuer(f *Field, c element.Column) *Valuer

NewValuer 创建新赋值器

func (*Valuer) Value

func (v *Valuer) Value() (value driver.Value, err error)

Value 赋值

Jump to

Keyboard shortcuts

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