Documentation ¶
Index ¶
- Constants
- Variables
- func Bool_opt(opt bool_option, enable bool) option
- func Debug(w io.Writer) option
- func Get_sql_type(i int16) string
- func Int_opt(opt int_option, i uint64) option
- func Register(address string, login Login, odbc_dsn string, opt ...option) (driver_name string)
- type Conn
- func (o *Conn) Begin() (driver.Tx, error)
- func (o *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (tx driver.Tx, err error)
- func (o *Conn) CheckNamedValue(nv *driver.NamedValue) (err error)
- func (o *Conn) Close() error
- func (o *Conn) Commit() (err error)
- func (o *Conn) Exec(args []driver.Value) (dr driver.Result, err error)
- func (o *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Result, err error)
- func (o *Conn) Ping(ctx context.Context) (err error)
- func (o *Conn) Prepare(query string) (ds driver.Stmt, err error)
- func (o *Conn) PrepareContext(ctx context.Context, query string) (ds driver.Stmt, err error)
- func (o *Conn) Query(args []driver.Value) (dr driver.Rows, err error)
- func (o *Conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Rows, err error)
- func (o *Conn) ResetSession(ctx context.Context) (err error)
- func (o *Conn) Rollback() (err error)
- type Driver
- type Err
- type Identity_table
- type Login
- type Rows
- type Stmt
- func (o *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error)
- func (o *Stmt) Close() error
- func (o *Stmt) Columns() (s []string)
- func (o *Stmt) Exec(args []driver.Value) (dr driver.Result, err error)
- func (o *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (dr driver.Result, err error)
- func (o *Stmt) LastInsertId() (id int64, err error)
- func (o *Stmt) Next(dest []driver.Value) (err error)
- func (o *Stmt) NumInput() int
- func (o *Stmt) Query(args []driver.Value) (dr driver.Rows, err error)
- func (o *Stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (dr driver.Rows, err error)
- func (o *Stmt) RowsAffected() (i int64, err error)
Examples ¶
Constants ¶
View Source
const ( Default_port = 2799 // Queries with this prefix will be executed and not prepared // The prefix is removed Execute_prefix = `odbexecute` // Special odbtp query. Use in QueryContext(). // https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/catalog-functions-in-odbc Sql_get_type_info = Execute_prefix + "||SQLGetTypeInfo" Sql_tables = Execute_prefix + "||SQLTables|||" Sql_columns = Execute_prefix + "||SQLColumns|||" // must append "<table>", and optional "|column" )
View Source
const ( Normal Login = C.ODB_LOGIN_NORMAL Reserved = C.ODB_LOGIN_RESERVED Single = C.ODB_LOGIN_SINGLE )
View Source
const ( // Example in query: {{.id}} becomes sql.Named("id", <value>) Prepare_is_template bool_option = 1 << iota * -1 // ODB_ATTR are positive // Zero_scan will cause Stmt.Scan() to return go zero values in place of nil // for database null Zero_scan // http://odbtp.sourceforge.net/clilib.html#attributes Cache_procs = C.ODB_ATTR_CACHEPROCS Mapchar2wchar = C.ODB_ATTR_MAPCHARTOWCHAR Describe_params = C.ODB_ATTR_DESCRIBEPARAMS Unicodesql = C.ODB_ATTR_UNICODESQL Right_trim_text = C.ODB_ATTR_RIGHTTRIMTEXT )
View Source
const ( Query_timeout int_option = C.ODB_ATTR_QUERYTIMEOUT Vardatasize = C.ODB_ATTR_VARDATASIZE )
Variables ¶
View Source
var ( // string or []byte input parameter to be set to database null Ns *string // int64 input parameter to be set to database null Ni *int64 // float64 input parameter to be set to database null Nf *float64 // bool input parameter to be set to database null Nb *bool // time.Time input parameter to be set to database null Nt *time.Time )
Functions ¶
func Get_sql_type ¶
Used with Sql_get_type_info query DATA_TYPE column
func Register ¶
Returns the registered driver name to use in sql.Open(). The driver name pattern is odbtp_msaccess_1, odbtp_msaccess_2, odbtp_msaccess_...
Example ¶
package main import ( "database/sql" "fmt" "github.com/aletheia7/odb" ) func main() { // Returns the registered driver name to use in sql.Open(). The driver name pattern is // odbtp_msaccess_1, odbtp_msaccess_... driver_name := odb.Register( "<host_name>", odb.Normal, `DRIVER=Microsoft Access Driver (*.mdb);DBQ=c:/<file path to mdb>;ImplicitCommitSync=Yes`, odb.Int_opt(odb.Query_timeout, 20), odb.Bool_opt(odb.Unicodesql, true), odb.Bool_opt(odb.Describe_params, true), odb.Bool_opt(odb.Mapchar2wchar, true), odb.Bool_opt(odb.Prepare_is_template, true), ) db, err := sql.Open(driver_name, ``) if err != nil { fmt.Print(err) return } defer db.Close() }
Output:
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
func (*Conn) CheckNamedValue ¶
func (o *Conn) CheckNamedValue(nv *driver.NamedValue) (err error)
func (*Conn) ExecContext ¶
func (o *Conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (dr driver.Result, err error)
msaccess: Must add an Identity_table arg to call LastInsertId()
func (*Conn) PrepareContext ¶
func (*Conn) QueryContext ¶
type Stmt ¶
type Stmt struct {
// contains filtered or unexported fields
}
func (*Stmt) CheckNamedValue ¶
func (o *Stmt) CheckNamedValue(nv *driver.NamedValue) (err error)
func (*Stmt) ExecContext ¶
func (o *Stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (dr driver.Result, err error)
msaccess: Must add an Identity_table arg to call LastInsertId()
func (*Stmt) LastInsertId ¶
Only usefull with msaccess
func (*Stmt) QueryContext ¶
func (*Stmt) RowsAffected ¶
Click to show internal directories.
Click to hide internal directories.