dbmaker

package module
v0.0.0-...-5e953f3 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2017 License: BSD-3-Clause Imports: 12 Imported by: 0

README

dbmaker driver is the odbc-compatible driver for DBMaker database management system. It calls into dmapi54.dll on Windows, and use cgo dynamic linked to libdmapic.so on Linux. NOTE, dbmaker doesn't use unixODBC or windows ODBC Driver Manager.

On windows, you should add the path contains dmapi54.dll into the env variable %PATH%, then run your program. e.g.

set PATH=C:\DBMaker\5.4\bin;%PATH%
go test github.com/dbmaker-go/dbmaker

If you want to switch to DBMaker 5.5, you should modify zapi_windows.go to load dmapi55.dll

  moddmapi54 = syscall.NewLazyDLL("dmapi55.dll")

On linux, you can modify cgo linux LDFLAGS/CFLAGS of api_unix.go/zapi_unix.go to swith to DBMaker 5.5.

The cgo flags for static linking to libdmapic.a:

// #cgo linux LDFLAGS: -ldmapic -ldl -lm -L/home/dbmaker/5.4/lib
// #cgo linux CFLAGS: -I/home/dbmaker/5.4/include
// #include "sql.h"
// #include "sqlext.h"

For dynamic linking to libdmapic.so:

// #cgo linux LDFLAGS: -ldmapic  -L/home/dbmaker/5.4/lib/so
// #cgo linux CFLAGS: -I/home/dbmaker/5.4/include
// #include "sql.h"
// #include "sqlext.h"

If using libdmapic.so, env variable LD_LIBRARY_PATH must contain the path in where libdmapic.so resided. e.g.:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dbmaker/5.4/lib/so
go test github.com/dbmaker-go/dbmaker ## need start DBSAMPLE5 DB before hand.

A simple example:

import (
    "database/sql"
    _ "github.com/dbmaker-go/dbmaker"
)

func main(){
	db, err := sql.Open("dbmaker","DSN=DB1;UID=SYSADM;PWD=xxx;");
	db.Query(...)
	//...
}

For more information about DBMaker, please refer to www.dbmaker.com.tw .

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsError

func IsError(ret api.SQLRETURN) bool

func NewError

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

func ToHandleAndType

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

Types

type BaseColumn

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

BaseColumn implements common column functionality.

func (*BaseColumn) Name

func (c *BaseColumn) Name() string

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
}

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 Column

type Column interface {
	Name() string
	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(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() (err error)

func (*Conn) Prepare

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

func (*Conn) PrepareODBCStmt

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

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() error

func (*ODBCStmt) Exec

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

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
	// contains filtered or unexported fields
}

func ExtractParameters

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

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 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) Columns

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

func (*Rows) Next

func (r *Rows) Next(dest []driver.Value) 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) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

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

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

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

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