shentong

package module
v0.0.0-...-ea1365e Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 19 Imported by: 0

README

goshentong

介绍

Golang Shentong database driver conforming to the Go database/sql interface

安装

go get github.com/wb253/goshentong

新建文件 aci.pc, 内容

prefix=/usr includedir=/opt/ShenTong/aci/include libdir=/opt/ShenTong/aci/linux64

Name: aci Description: Shentong Client Version: 1.0 Cflags: -I${includedir} Libs: -L${libdir} -laci

设置环境变量 export LD_LIBRARY_PATH=/opt/ShenTong/aci/linux64 export PKG_CONFIG_PATH=aci.pc所在目录

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOCIInvalidHandle is OCI_INVALID_HANDLE
	ErrOCIInvalidHandle = errors.New("OCI_INVALID_HANDLE")
	// ErrOCISuccessWithInfo is OCI_SUCCESS_WITH_INFO
	ErrOCISuccessWithInfo = errors.New("OCI_SUCCESS_WITH_INFO")
	// ErrOCIReservedForIntUse is OCI_RESERVED_FOR_INT_USE
	ErrOCIReservedForIntUse = errors.New("OCI_RESERVED_FOR_INT_USE")
	// ErrOCINoData is OCI_NO_DATA
	ErrOCINoData = errors.New("OCI_NO_DATA")
	// ErrOCINeedData is OCI_NEED_DATA
	ErrOCINeedData = errors.New("OCI_NEED_DATA")
	// ErrOCIStillExecuting is OCI_STILL_EXECUTING
	ErrOCIStillExecuting = errors.New("OCI_STILL_EXECUTING")

	// ErrNoRowid is result has no rowid
	ErrNoRowid = errors.New("result has no rowid")

	// Driver is the sql driver
	Driver = &DriverStruct{
		Logger: log.New(ioutil.Discard, "", 0),
	}
)

Functions

func GetLastInsertId

func GetLastInsertId(id int64) string

GetLastInsertId returns rowid from LastInsertId

func NewConnector

func NewConnector(hosts ...string) driver.Connector

NewConnector returns a new database connector

func QueryEscape

func QueryEscape(s string) string

QueryEscape escapes the string so it can be safely placed inside a URL query.

func QueryUnescape

func QueryUnescape(s string) (string, error)

QueryUnescape does the inverse transformation of QueryEscape, converting %AB into the byte 0xAB and '+' into ' ' (space). It returns an error if any % is not followed by two hexadecimal digits.

Types

type Conn

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

Conn is Oracle connection

func (*Conn) Begin

func (conn *Conn) Begin() (driver.Tx, error)

Begin starts a transaction

func (*Conn) BeginTx

func (conn *Conn) BeginTx(ctx context.Context, txOptions driver.TxOptions) (driver.Tx, error)

BeginTx starts a transaction

func (*Conn) Close

func (conn *Conn) Close() error

Close a connection

func (*Conn) Ping

func (conn *Conn) Ping(ctx context.Context) error

Ping database connection

func (*Conn) Prepare

func (conn *Conn) Prepare(query string) (driver.Stmt, error)

Prepare prepares a query

func (*Conn) PrepareContext

func (conn *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

PrepareContext prepares a query with context

type Connector

type Connector struct {
	// Logger is used to log connection ping errors
	Logger *log.Logger
}

Connector is the sql driver connector

func (*Connector) Connect

func (connector *Connector) Connect(ctx context.Context) (driver.Conn, error)

Connect returns a new database connection

func (*Connector) Driver

func (connector *Connector) Driver() driver.Driver

Driver returns the OCI8 driver

type DSN

type DSN struct {
	Connect  string
	Username string
	Password string
	// contains filtered or unexported fields
}

DSN is Oracle Data Source Name

func ParseDSN

func ParseDSN(dsnString string) (dsn *DSN, err error)

ParseDSN parses a DSN used to connect to Oracle

It expects to receive a string in the form:

[username/[password]@]host[:port][/service_name][?param1=value1&...&paramN=valueN]

Connection timeout can be set in the Oracle files: sqlnet.ora as SQLNET.OUTBOUND_CONNECT_TIMEOUT or tnsnames.ora as CONNECT_TIMEOUT

Supported parameters are:

loc - the time location for reading timestamp (without time zone). Defaults to UTC Note that writing a timestamp (without time zone) just truncates the time zone.

isolation - the isolation level that can be set to: READONLY, SERIALIZABLE, or DEFAULT

prefetch_rows - the number of top level rows to be prefetched. Defaults to 0. A 0 means unlimited rows.

prefetch_memory - the max memory for top level rows to be prefetched. Defaults to 4096. A 0 means unlimited memory.

questionph - when true, enables question mark placeholders. Defaults to false. (uses strconv.ParseBool to check for true)

type DriverStruct

type DriverStruct struct {
	// Logger is used to log connection ping errors, defaults to discard
	// To log set it to something like: log.New(os.Stderr, "oci8 ", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile)
	Logger *log.Logger
}

DriverStruct is Oracle driver struct

func (*DriverStruct) Open

func (drv *DriverStruct) Open(dsnString string) (driver.Conn, error)

Open opens a new database connection

type EscapeError

type EscapeError string

EscapeError for invalid escape

func (EscapeError) Error

func (e EscapeError) Error() string

Error returns string for invalid URL escape

type Result

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

Result is Oracle result

func (*Result) LastInsertId

func (result *Result) LastInsertId() (int64, error)

LastInsertId returns last inserted ID

func (*Result) RowsAffected

func (result *Result) RowsAffected() (int64, error)

RowsAffected returns rows affected

type Rows

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

Rows is Oracle rows

func (*Rows) Close

func (rows *Rows) Close() error

Close closes rows

func (*Rows) ColumnTypeDatabaseTypeName

func (rows *Rows) ColumnTypeDatabaseTypeName(i int) string

ColumnTypeDatabaseTypeName implement RowsColumnTypeDatabaseTypeName.

func (*Rows) ColumnTypeLength

func (rows *Rows) ColumnTypeLength(i int) (int64, bool)

ColumnTypeLength is returning OCI_ATTR_DATA_SIZE, which is max data size in bytes. Note this is not returing length of the column type, like the 20 in FLOAT(20), which is what is normally expected. TODO: Should / can it be changed to return length of the column type?

func (*Rows) ColumnTypeScanType

func (rows *Rows) ColumnTypeScanType(i int) reflect.Type

ColumnTypeScanType implement RowsColumnTypeScanType.

func (*Rows) Columns

func (rows *Rows) Columns() []string

Columns returns column names

func (*Rows) Next

func (rows *Rows) Next(dest []driver.Value) error

Next gets next row

type Stmt

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

Stmt is Oracle statement

func (*Stmt) CheckNamedValue

func (stmt *Stmt) CheckNamedValue(namedValue *driver.NamedValue) error

CheckNamedValue checks a named value

func (*Stmt) Close

func (stmt *Stmt) Close() error

Close closes the statement

func (*Stmt) Exec

func (stmt *Stmt) Exec(values []driver.Value) (driver.Result, error)

Exec runs an exec query

func (*Stmt) ExecContext

func (stmt *Stmt) ExecContext(ctx context.Context, namedValues []driver.NamedValue) (driver.Result, error)

ExecContext run a exec query with context

func (*Stmt) NumInput

func (stmt *Stmt) NumInput() int

NumInput returns the number of input

func (*Stmt) Query

func (stmt *Stmt) Query(values []driver.Value) (driver.Rows, error)

Query runs a query

func (*Stmt) QueryContext

func (stmt *Stmt) QueryContext(ctx context.Context, namedValues []driver.NamedValue) (driver.Rows, error)

QueryContext runs a query with context

type Tx

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

Tx is Oracle transaction

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit transaction commit

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback transaction rollback

type Values

type Values map[string][]string

Values maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Values map are case-sensitive.

func ParseQuery

func ParseQuery(query string) (m Values, err error)

ParseQuery parses the URL-encoded query string and returns a map listing the values specified for each key. ParseQuery always returns a non-nil map containing all the valid query parameters found; err describes the first decoding error encountered, if any.

func (Values) Add

func (v Values) Add(key, value string)

Add adds the value to key. It appends to any existing values associated with key.

func (Values) Del

func (v Values) Del(key string)

Del deletes the values associated with key.

func (Values) Encode

func (v Values) Encode() string

Encode encodes the values into “URL encoded” form ("bar=baz&foo=quux") not sorted by key

func (Values) Get

func (v Values) Get(key string) string

Get gets the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.

func (Values) Set

func (v Values) Set(key, value string)

Set sets the key to value. It replaces any existing values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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