godbc

package module
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: BSD-3-Clause Imports: 18 Imported by: 0

README

godbc

Interface for GoLang to DB2 for z/OS, DB2 for LUW, DB2 for i. I merge code from following two repos https://github.com/alexbrainman/odbc https://github.com/ibmdb/go_ibm_db

API Documentation

For complete list of godbc APIs and examples please check APIDocumentation.md

Prerequisite

Golang should be installed(Golang version should be >=1.12.x and <= 1.19.X)

Git should be installed in your system.

For non-windows users, GCC and tar should be present in your system.

For Docker Linux Container(Ex: Amazon Linux2), use below commands:
yum install go git tar libpam

Note:

Environment variable DB2HOME name is changed to IBM_DB_HOME.

How to Install in Windows

You may install godbc using either of below commands
go get -d github.com/onlysumitg/godbc
go install github.com/onlysumitg/godbc/installer@latest
go install github.com/onlysumitg/godbc/installer@v0.4.2

If you already have a clidriver available in your system, add the path of the same to your Path windows environment variable
Example: Path = C:\Program Files\IBM\IBM DATA SERVER DRIVER\bin


If you do not have a clidriver in your system, go to installer folder where godbc is downloaded in your system, use below command: 
(Example: C:\Users\uname\go\src\github.com\ibmdb\godbc\installer or C:\Users\uname\go\pkg\mod\github.com\ibmdb\godbc\installer 
 where uname is the username ) and run setup.go file (go run setup.go).


Set IBM_DB_HOME to clidriver downloaded path and
set this path to your PATH windows environment variable
(Example: Path=C:\Users\uname\go\src\github.com\ibmdb\clidriver)
set IBM_DB_HOME=C:\Users\uname\go\src\github.com\ibmdb\clidriver
set PATH=%PATH%;C:\Users\uname\go\src\github.com\ibmdb\clidriver\bin
or 
set PATH=%PATH%;%IBM_DB_HOME%\bin



Script file to set environment variable 
cd .../godbc/installer
setenvwin.bat

How to Install in Linux/Mac

You may install godbc using either of below commands
go get -d github.com/onlysumitg/godbc
go install github.com/onlysumitg/godbc/installer@latest
go install github.com/onlysumitg/godbc/installer@v0.4.2


If you already have a clidriver available in your system, set the below environment variables with the clidriver path

export IBM_DB_HOME=/home/uname/clidriver
export CGO_CFLAGS=-I$IBM_DB_HOME/include
export CGO_LDFLAGS=-L$IBM_DB_HOME/lib 
Linux:
export LD_LIBRARY_PATH=/home/uname/clidriver/lib
or
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IBM_DB_HOME/lib
Mac:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Applications/clidriver/lib

If you do not have a clidriver available in your system, use below command:
go to installer folder where godbc is downloaded in your system 
(Example: /home/uname/go/src/github.com/onlysumitg/godbc/installer or /home/uname/go/pkg/mod/github.com/onlysumitg/godbc/installer 
where uname is the username) and run setup.go file (go run setup.go)

Set the below environment variables with the path of the clidriver downloaded

export IBM_DB_HOME=/home/uname/go/src/github.com/ibmdb/clidriver
export CGO_CFLAGS=-I$IBM_DB_HOME/include
export CGO_LDFLAGS=-L$IBM_DB_HOME/lib
Linux:
export LD_LIBRARY_PATH=/home/uname/go/src/github.com/ibmdb/clidriver/lib
or
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$IBM_DB_HOME/lib
Mac:
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/home/uname/go/src/github.com/ibmdb/clidriver/lib
or
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$IBM_DB_HOME/lib


Script file to set environment variables in Linux/Mac 
cd .../godbc/installer
source setenv.sh

For Docker Linux Container, use below commands
yum install -y gcc git go wget tar xz make gcc-c++
cd /root
curl -OL https://golang.org/dl/go1.17.X.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.17.X.linux-amd64.tar.gz

rm /usr/bin/go
rm /usr/bin/gofmt
cp /usr/local/go/bin/go /usr/bin/
cp /usr/local/go/bin/gofmt /usr/bin/

go install github.com/onlysumitg/godbc/installer@v0.4.2
or 
go install github.com/onlysumitg/godbc/installer@latest

License requirements for connecting to databases

godbc driver can connect to DB2 on Linux Unix and Windows without any additional license/s, however, connecting to databases on DB2 for z/OS or DB2 for i(AS400) Servers require either client side or server side license/s. The client side license would need to be copied under license folder of your clidriver installation directory and for activating server side license, you would need to purchase DB2 Connect Unlimited Edition for System z® and DB2 Connect Unlimited Edition for System i®.

To know more about license and purchasing cost, please contact IBM Customer Support.

To know more about server based licensing viz db2connectactivate, follow below links:

How to run sample program

example1.go:-
package main

import (
	"database/sql"
	"fmt"
	_ "github.com/onlysumitg/godbc"
)

func main() {
	con := "HOSTNAME=host;DATABASE=name;PORT=number;UID=username;PWD=password"
	db, err := sql.Open("godbc", con)
	if err != nil {
		fmt.Println(err)
	}
	db.Close()
}

To run the sample:- go run example1.go

For complete list of connection parameters please check this.

example2.go:-
package main

import (
	"database/sql"
	"fmt"
	_ "github.com/onlysumitg/godbc"
)

func Create_Con(con string) *sql.DB {
	db, err := sql.Open("godbc", con)
	if err != nil {
		fmt.Println(err)
		return nil
	}
	return db
}

// Creating a table.

func create(db *sql.DB) error {
	_, err := db.Exec("DROP table SAMPLE")
	if err != nil {
		_, err := db.Exec("create table SAMPLE(ID varchar(20),NAME varchar(20),LOCATION varchar(20),POSITION varchar(20))")
		if err != nil {
			return err
		}
	} else {
		_, err := db.Exec("create table SAMPLE(ID varchar(20),NAME varchar(20),LOCATION varchar(20),POSITION varchar(20))")
		if err != nil {
			return err
		}
	}
	fmt.Println("TABLE CREATED")
	return nil
}

// Inserting row.

func insert(db *sql.DB) error {
	st, err := db.Prepare("Insert into SAMPLE(ID,NAME,LOCATION,POSITION) values('3242','mike','hyd','manager')")
	if err != nil {
		return err
	}
	st.Query()
	return nil
}

// This API selects the data from the table and prints it.

func display(db *sql.DB) error {
	st, err := db.Prepare("select * from SAMPLE")
	if err != nil {
		return err
	}
	err = execquery(st)
	if err != nil {
		return err
	}
	return nil
}

func execquery(st *sql.Stmt) error {
	rows, err := st.Query()
	if err != nil {
		return err
	}
	defer rows.Close()
	cols, _ := rows.Columns()
	fmt.Printf("%s    %s   %s    %s\n", cols[0], cols[1], cols[2], cols[3])
	fmt.Println("-------------------------------------")
	for rows.Next() {
		var t, x, m, n string
		err = rows.Scan(&t, &x, &m, &n)
		if err != nil {
			return err
		}
		fmt.Printf("%v  %v   %v         %v\n", t, x, m, n)
	}
	return nil
}

func main() {
	con := "HOSTNAME=host;DATABASE=name;PORT=number;UID=username;PWD=password"
	type Db *sql.DB
	var re Db
	re = Create_Con(con)
	err := create(re)
	if err != nil {
		fmt.Println(err)
	}
	err = insert(re)
	if err != nil {
		fmt.Println(err)
	}
	err = display(re)
	if err != nil {
		fmt.Println(err)
	}
}

To run the sample:- go run example2.go

example3.go:-(POOLING)
package main

import (
	_ "database/sql"
	"fmt"
	a "github.com/onlysumitg/godbc"
)

func main() {
	con := "HOSTNAME=host;PORT=number;DATABASE=name;UID=username;PWD=password"
	pool := a.Pconnect("PoolSize=100")

	// SetConnMaxLifetime will take the value in SECONDS
	db := pool.Open(con, "SetConnMaxLifetime=30")
	st, err := db.Prepare("Insert into SAMPLE values('hi','hi','hi','hi')")
	if err != nil {
		fmt.Println(err)
	}
	st.Query()

	// Here the time out is default.
	db1 := pool.Open(con)
	st1, err := db1.Prepare("Insert into SAMPLE values('hi1','hi1','hi1','hi1')")
	if err != nil {
		fmt.Println(err)
	}
	st1.Query()

	db1.Close()
	db.Close()
	pool.Release()
	fmt.println("success")
}

To run the sample:- go run example3.go

example4.go:-(POOLING- Limit on the number of connections)
package main

import (
           "database/sql"
           "fmt"
           "time"
          a "github.com/onlysumitg/godbc"
       )

func ExecQuery(st *sql.Stmt) error {
        res, err := st.Query()
        if err != nil {
             fmt.Println(err)
        }
        cols, _ := res.Columns()

        fmt.Printf("%s    %s   %s     %s\n", cols[0], cols[1], cols[2], cols[3])
        defer res.Close()
        for res.Next() {
                    var t, x, m, n string
                    err = res.Scan(&t, &x, &m, &n)
                    fmt.Printf("%v  %v   %v     %v\n", t, x, m, n)
        }
        return nil
}

func main() {
	con := "HOSTNAME=host;PORT=number;DATABASE=name;UID=username;PWD=password"
        pool := a.Pconnect("PoolSize=5")

        ret := pool.Init(5, con)
        if ret != true {
                fmt.Println("Pool initializtion failed")
        }

        for i:=0; i<20; i++ {
                db1 := pool.Open(con, "SetConnMaxLifetime=10")
                if db1 != nil {
                        st1, err1 := db1.Prepare("select * from VMSAMPLE")
                        if err1 != nil {
                                fmt.Println("err1 : ", err1)
                        }else{
                                go func() {
                                        execquery(st1)
                                        db1.Close()
                                }()
                        }
                }
        }
        time.Sleep(30*time.Second)
        pool.Release()
}

To run the sample:- go run example4.go

For Running the Tests:

  1. Put your connection string in the main.go file in testdata folder

  2. Now run go test command (use go test -v command for details)

  3. To run a particular test case (use "go test sample_test.go main.go", example "go test Arraystring_test.go main.go")

Documentation

Overview

Package odbc implements database/sql driver to access data via odbc interface.

Index

Constants

This section is empty.

Variables

View Source
var DB2SpecialResigers map[string]func([]byte) []byte = map[string]func([]byte) []byte{
	"CURRENT CLIENT_ACCTNG":            Dummy,
	"CLIENT ACCTNG":                    Dummy,
	"CURRENT CLIENT_APPLNAME":          Dummy,
	"CLIENT APPLNAME":                  Dummy,
	"CURRENT CLIENT_PROGRAMID":         Dummy,
	"CLIENT PROGRAMID":                 Dummy,
	"CURRENT CLIENT_USERID":            Dummy,
	"CLIENT USERID":                    Dummy,
	"CURRENT CLIENT_WRKSTNNAME":        Dummy,
	"CLIENT WRKSTNNAME":                Dummy,
	"CURRENT DATE":                     Dummy,
	"CURRENT_DATE":                     Dummy,
	"CURRENT DEBUG MODE":               Dummy,
	"CURRENT DECFLOAT ROUNDING MODE":   Dummy,
	"CURRENT DEGREE":                   Dummy,
	"CURRENT IMPLICIT XMLPARSE OPTION": Dummy,
	"CURRENT PATH":                     Dummy,
	"CURRENT_PATH":                     Dummy,
	"CURRENT FUNCTION PATH":            Dummy,
	"CURRENT SCHEMA":                   Dummy,
	"CURRENT SERVER":                   Dummy,
	"CURRENT_SERVER":                   Dummy,
	"CURRENT TEMPORAL SYSTEM_TIME":     Dummy,
	"CURRENT TIME":                     Dummy,
	"CURRENT_TIME":                     Dummy,
	"CURRENT TIMESTAMP":                Dummy,
	"CURRENT_TIMESTAMP":                Dummy,
	"CURRENT TIMEZONE":                 Dummy,
	"CURRENT_TIMEZONE":                 Dummy,
	"CURRENT USER":                     Dummy,
	"CURRENT_USER":                     Dummy,
	"SESSION_USER":                     Dummy,
	"USER":                             Dummy,
	"SYSTEM_USER":                      Dummy,

	"CURRENT ACCELERATOR":                    Dummy,
	"CURRENT APPLICATION COMPATIBILITY":      Dummy,
	"CURRENT APPLICATION ENCODING SCHEME":    Dummy,
	"CURRENT CLIENT_CORR_TOKEN":              Dummy,
	"CURRENT EXPLAIN MODE":                   Dummy,
	"CURRENT GET_ACCEL_ARCHIVE":              Dummy,
	"CURRENT_LC_CTYPE":                       Dummy,
	"CURRENT LOCALE LC_CTYPE":                Dummy,
	"CURRENT MAINTAINED":                     Dummy,
	"CURRENT MEMBER":                         Dummy,
	"CURRENT OPTIMIZATION HINT":              Dummy,
	"CURRENT PACKAGE PATH":                   Dummy,
	"CURRENT PACKAGESET":                     Dummy,
	"CURRENT PRECISION":                      Dummy,
	"CURRENT QUERY ACCELERATION":             Dummy,
	"CURRENT QUERY ACCELERATION WAITFORDATA": Dummy,
	"CURRENT REFRESH AGE":                    Dummy,
	"CURRENT ROUTINE VERSION":                Dummy,
	"CURRENT RULES":                          Dummy,
	"CURRENT_SCHEMA":                         Dummy,
	"CURRENT SQLID":                          Dummy,
	"CURRENT TEMPORAL BUSINESS_TIME":         Dummy,
	"CURRENT TIME ZONE":                      Dummy,
	"ENCRYPTION PASSWORD":                    Dummy,
	"SESSION TIME ZONE":                      Dummy,
}
View Source
var DateFormat string = "2006-01-02"
View Source
var SPParamDataTypes map[string]string = map[string]string{

	"SMALLINT":         "NUMERIC",
	"BIGINT":           "NUMERIC",
	"ROWID":            "NUMERIC",
	"DECIMAL":          "NUMERIC",
	"NUMERIC":          "NUMERIC",
	"INTEGER":          "NUMERIC",
	"DOUBLE PRECISION": "NUMERIC",
	"REAL":             "NUMERIC",

	"CHARACTER":                          "STRING",
	"BINARY VARYING":                     "STRING",
	"XML":                                "STRING",
	"BINARY LARGE OBJECT":                "STRING",
	"GRAPHIC VARYING":                    "STRING",
	"CHARACTER VARYING":                  "STRING",
	"BINARY":                             "STRING",
	"CHARACTER LARGE OBJECT":             "STRING",
	"GRAPHIC":                            "STRING",
	"DOUBLE-BYTE CHARACTER LARGE OBJECT": "STRING",

	"TIME":      "DATE",
	"DATE":      "DATE",
	"TIMESTAMP": "DATE",
}
View Source
var SPParamDateTypes map[string]string = map[string]string{

	"TIME":      "DATE",
	"DATE":      "DATE",
	"TIMESTAMP": "DATE",
}
View Source
var SPParamIntegerTypes map[string]string = map[string]string{

	"SMALLINT": "NUMERIC",
	"BIGINT":   "NUMERIC",
	"INTEGER":  "NUMERIC",
}

without decimal point

View Source
var SPParamNumericTypes map[string]string = map[string]string{

	"SMALLINT":         "NUMERIC",
	"BIGINT":           "NUMERIC",
	"ROWID":            "NUMERIC",
	"DECIMAL":          "NUMERIC",
	"NUMERIC":          "NUMERIC",
	"INTEGER":          "NUMERIC",
	"DOUBLE PRECISION": "NUMERIC",
	"REAL":             "NUMERIC",
}
View Source
var SPParamStringTypes map[string]string = map[string]string{

	"CHARACTER":                          "STRING",
	"BINARY VARYING":                     "STRING",
	"XML":                                "STRING",
	"BINARY LARGE OBJECT":                "STRING",
	"GRAPHIC VARYING":                    "STRING",
	"CHARACTER VARYING":                  "STRING",
	"BINARY":                             "STRING",
	"CHARACTER LARGE OBJECT":             "STRING",
	"GRAPHIC":                            "STRING",
	"DOUBLE-BYTE CHARACTER LARGE OBJECT": "STRING",
}
View Source
var TimeFormat string = "15:04:05"
View Source
var TimestampFormat string = "2006-01-02 15:04:05.000000"

Functions

func CURRENT_DATE

func CURRENT_DATE(x []byte) []byte

func CURRENT_TIME

func CURRENT_TIME(x []byte) []byte

func ConvertAssign

func ConvertAssign(dest, src interface{}) error

ConvertAssign function copies the database data to Dest field in stored procedure.

func CreateDb

func CreateDb(dbname string, connStr string, options ...string) (bool, error)

CreateDb function will take the db name and user details as parameters and create the database.

func DropDb

func DropDb(dbname string, connStr string) (bool, error)

DropDb function will take the db name and user details as parameters and drop the database.

func Dummy

func Dummy(x []byte) []byte

func GetSepecialValue

func GetSepecialValue(name string, param []byte) []byte

func IsError

func IsError(ret api.SQLRETURN) bool

func IsSepecialRegister

func IsSepecialRegister(name string) bool

func NewError

func NewError(apiName string, handle interface{}) error

func SqltoCtype

func SqltoCtype(sqltype api.SQLSMALLINT) api.SQLSMALLINT

SqltoCtype function will convert the sql type to c type

func ToHandleAndType

func ToHandleAndType(handle interface{}) (h api.SQLHANDLE, ht api.SQLSMALLINT)

Types

type BaseColumn

type BaseColumn struct {
	CType api.SQLSMALLINT
	SType api.SQLSMALLINT
	// contains filtered or unexported fields
}

BaseColumn implements common column functionality.

func (*BaseColumn) Name

func (c *BaseColumn) Name() string

func (*BaseColumn) TypeScan

func (c *BaseColumn) TypeScan() reflect.Type

func (*BaseColumn) Value

func (c *BaseColumn) Value(buf []byte) (driver.Value, error)

type BindableColumn

type BindableColumn struct {
	*BaseColumn
	IsBound         bool
	IsVariableWidth bool
	Size            int
	Len             BufferLen
	Buffer          []byte
	// contains filtered or unexported fields
}

BindableColumn allows access to columns that can have their buffers bound. Once bound at start, they are written to by odbc driver every time it fetches new row. This saves on syscall and, perhaps, some buffer copying. BindableColumn can be left unbound, then it behaves like NonBindableColumn when user reads data from it.

func NewBindableColumn

func NewBindableColumn(b *BaseColumn, ctype api.SQLSMALLINT, bufSize int) *BindableColumn

func (*BindableColumn) Bind

func (c *BindableColumn) Bind(h api.SQLHSTMT, idx int) (bool, error)

func (*BindableColumn) Value

func (c *BindableColumn) Value(h api.SQLHSTMT, idx int) (driver.Value, error)

type BufferLen

type BufferLen api.SQLLEN

func (*BufferLen) Bind

func (l *BufferLen) Bind(h api.SQLHSTMT, idx int, ctype api.SQLSMALLINT, buf []byte) api.SQLRETURN

func (*BufferLen) GetData

func (l *BufferLen) GetData(h api.SQLHSTMT, idx int, ctype api.SQLSMALLINT, buf []byte) api.SQLRETURN

func (*BufferLen) IsNull

func (l *BufferLen) IsNull() bool

type Col

type Col struct {
	Index int `json:"-"`
	Name  string
	Type  reflect.Type `json:"-"`
	Value any
}

func (*Col) AssignValueByType

func (c *Col) AssignValueByType()

type Column

type Column interface {
	Name() string
	TypeScan() reflect.Type
	Bind(h api.SQLHSTMT, idx int) (bool, error)
	Value(h api.SQLHSTMT, idx int) (driver.Value, error)
}

Column provides access to row columns.

func NewColumn

func NewColumn(ctx context.Context, h api.SQLHSTMT, idx int) (Column, error)

func NewVariableWidthColumn

func NewVariableWidthColumn(b *BaseColumn, ctype api.SQLSMALLINT, colWidth api.SQLULEN) Column

type Conn

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

func (*Conn) Begin

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Ping

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

func (*Conn) Prepare

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

func (*Conn) PrepareContext

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

func (*Conn) PrepareODBCStmt

func (c *Conn) PrepareODBCStmt(query string) (*ODBCStmt, error)

func (*Conn) Query

func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)

Query method executes the statement with out prepare if no args provided, and a driver.ErrSkip otherwise (handled by sql.go to execute usual preparedStmt)

func (*Conn) QueryContext

func (c *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error)

type ContextKey

type ContextKey string
const DUMMY_SP_CALL ContextKey = "DUMMY_SP_CALL"
const ESCAPE_QUOTE ContextKey = "ESCAPE_QUOTE"
const LABEL_IN_COL_NAME ContextKey = "LABEL_IN_COL_NAME"
const LOAD_SP_RESULT_SETS ContextKey = "LOAD_SP_RESULT_SETS"
const SQL_TO_PING ContextKey = "SQL_TO_PIGN"

type DBP

type DBP struct {
	sql.DB
	// contains filtered or unexported fields
}

DBP struct type contains the timeout, dbinstance and connection string

func (*DBP) Close

func (d *DBP) Close()

Close will make the connection available for the next release

func (*DBP) Timeout

func (d *DBP) Timeout()

Timeout for closing the connection in pool

type DiagRecord

type DiagRecord struct {
	State       string
	NativeError int
	Message     string
}

func (*DiagRecord) String

func (r *DiagRecord) String() string

type Driver

type Driver struct {
	Stats
	// contains filtered or unexported fields
}

func (*Driver) Close

func (d *Driver) Close() error

func (*Driver) Open

func (d *Driver) Open(dsn string) (driver.Conn, error)

type Error

type Error struct {
	APIName string
	Diag    []DiagRecord
}

func (*Error) Error

func (e *Error) Error() string

type NonBindableColumn

type NonBindableColumn struct {
	*BaseColumn
}

NonBindableColumn provide access to columns, that can't be bound. These are of character or binary type, and, usually, there is no limit for their width.

func (*NonBindableColumn) Bind

func (c *NonBindableColumn) Bind(h api.SQLHSTMT, idx int) (bool, error)

func (*NonBindableColumn) Value

func (c *NonBindableColumn) Value(h api.SQLHSTMT, idx int) (driver.Value, error)

type ODBCStmt

type ODBCStmt struct {
	Parameters []Parameter
	Cols       []Column
	// contains filtered or unexported fields
}

func (*ODBCStmt) BindColumns

func (s *ODBCStmt) BindColumns(ctx context.Context) error

func (*ODBCStmt) Exec

func (s *ODBCStmt) Exec(args []driver.Value) error

type Out

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

Out struct is used to store the value of a OUT parameter in Stored Procedure

func (*Out) ConvertAssign

func (o *Out) ConvertAssign() error

ConvertAssign function copies the database data to Dest field in stored procedure.

func (*Out) Value

func (o *Out) Value() (driver.Value, error)

this conver values from SQL to Go type Value function converts the database value to driver.value

type Parameter

type Parameter struct {
	SQLType api.SQLSMALLINT
	Decimal api.SQLSMALLINT
	Size    api.SQLULEN

	// Following fields store data used later by SQLExecute.
	// The fields keep data alive and away from gc.
	Data             interface{}
	StrLen_or_IndPtr api.SQLLEN
	Outs             []*Out
	// contains filtered or unexported fields
}

func ExtractParameters

func ExtractParameters(h api.SQLHSTMT) ([]Parameter, error)

ExtractParameters will describe all the parameters

func (*Parameter) BindValue

func (p *Parameter) BindValue(h api.SQLHSTMT, idx int, v driver.Value) error

func (*Parameter) StoreStrLen_or_IndPtr

func (p *Parameter) StoreStrLen_or_IndPtr(v api.SQLLEN) *api.SQLLEN

StoreStrLen_or_IndPtr stores v into StrLen_or_IndPtr field of p and returns address of that field.

type Pool

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

Pool struct contais the about the pool like size, used and available connections

func Pconnect

func Pconnect(poolSize string) *Pool

Pconnect will return the pool instance

func (*Pool) Display

func (p *Pool) Display()

Display will print the values in the map

func (*Pool) Init

func (p *Pool) Init(numConn int, connStr string) bool

func (*Pool) Open

func (p *Pool) Open(connStr string, options ...string) *DBP

Open will check for the connection in the pool If not opens a new connection and stores in the pool

func (*Pool) Release

func (p *Pool) Release()

Release will close all the connections in the pool

func (*Pool) SetConnMaxLifetime

func (p *Pool) SetConnMaxLifetime(num int)

Set the connMaxLifetime

type ROWID

type ROWID int64

type RSRows

type RSRows []Col

func (RSRows) ToMap

func (r RSRows) ToMap() map[string]any

type Result

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

func (*Result) LastInsertId

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

func (*Result) RowsAffected

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

type Rows

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

func (*Rows) Close

func (r *Rows) Close() error

func (*Rows) ColumnTypeDatabaseTypeName

func (r *Rows) ColumnTypeDatabaseTypeName(index int) string

func (*Rows) ColumnTypeLength

func (r *Rows) ColumnTypeLength(index int) (length int64, ok bool)

func (*Rows) ColumnTypeNullable

func (r *Rows) ColumnTypeNullable(index int) (nullable, ok bool)

func (*Rows) ColumnTypePrecisionScale

func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)

func (*Rows) ColumnTypeScanType

func (r *Rows) ColumnTypeScanType(index int) reflect.Type

func (*Rows) Columns

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

func (*Rows) HasNextResultSet

func (r *Rows) HasNextResultSet() bool

func (*Rows) Next

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

func (*Rows) NextResultSet

func (r *Rows) NextResultSet(ctx context.Context) error

type Stats

type Stats struct {
	EnvCount  int
	ConnCount int
	StmtCount int
	// contains filtered or unexported fields
}

type Stmt

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

func (*Stmt) CheckNamedValue

func (s *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error)

CheckNamedValue implementes driver.NamedValueChecker.

func (*Stmt) Close

func (s *Stmt) Close() error

Close closes the opened statement

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)

Exec executes the the sql but does not return the rows

func (*Stmt) ExecContext

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

ExecContext implements driver.StmtExecContext interface

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)

Query function executes the sql and return rows if rows are present

func (*Stmt) QueryContext

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

QueryContext implements driver.StmtQueryContext interface

type Tx

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

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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