gsql

package module
v0.0.0-...-07b9644 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

README

gsql


example

dbx, _ := gsql.New(`sqlite3`, `db00.sqlite`)
qry0 := dbx.NewQuery()
qry0.SetSQL(`SELECT * FROM t00`)
qry0.Open()
for qry0.Next() {
    for id := 0; id < qry0.FieldCount(); id++ {
        s0 := fmt.Sprintln(qry0.FieldById(id).AsString())
        log.Printf("[%d] %s", id, s0)
    }
}
//query row
qry0.GetOne()
for id := 0; id < qry0.FieldCount(); id++ {
    s0 := fmt.Sprintln(qry0.FieldById(id).AsString())
    log.Printf("[%d] %s", id, s0)
}
qry0.Close()

//use prepare
qry1 := dbx.NewQuery(true)
qry1.SetSQL(`SELECT * FROM t00 WHERE c00=?`)
qry1.GetOne(1)
qry1.GetOne(2)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBx

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

func New

func New(driverName, dataSourceName string) (dbx *DBx, err error)

func (*DBx) Close

func (this *DBx) Close() error

func (*DBx) NewQuery

func (this *DBx) NewQuery(args ...interface{}) *Query

func (*DBx) NewTrans

func (this *DBx) NewTrans() (t *Transaction, e error)

type Field

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

func (*Field) AsBool

func (this *Field) AsBool() (b bool, e error)

func (*Field) AsBytes

func (this *Field) AsBytes() (b []byte, e error)

func (*Field) AsFloat32

func (this *Field) AsFloat32() (f float32, e error)

func (*Field) AsFloat64

func (this *Field) AsFloat64() (f float64, e error)

func (*Field) AsInt64

func (this *Field) AsInt64() (n int64, e error)

func (*Field) AsString

func (this *Field) AsString() (s string, e error)

func (*Field) AsTime

func (this *Field) AsTime() (t time.Time, e error)

func (*Field) AsUint64

func (this *Field) AsUint64() (n uint64, e error)

func (*Field) IsNull

func (this *Field) IsNull() bool

func (*Field) ToBool

func (this *Field) ToBool() bool

func (*Field) ToBytes

func (this *Field) ToBytes() []byte

func (*Field) ToFloat32

func (this *Field) ToFloat32() float32

func (*Field) ToFloat64

func (this *Field) ToFloat64() float64

func (*Field) ToInt64

func (this *Field) ToInt64() (n int64)

func (*Field) ToString

func (this *Field) ToString() (s string)

func (*Field) ToTime

func (this *Field) ToTime() (t time.Time)

func (*Field) ToUint64

func (this *Field) ToUint64() uint64

type FieldType

type FieldType int

type Fields

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

type Query

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

func (*Query) Close

func (this *Query) Close() error

func (*Query) Exec

func (this *Query) Exec(args ...interface{}) (ret sql.Result, err error)

func (*Query) FieldById

func (this *Query) FieldById(id int) *Field

func (*Query) FieldByName

func (this *Query) FieldByName(name string) *Field

func (*Query) FieldCount

func (this *Query) FieldCount() int

func (*Query) First

func (this *Query) First() (err error)

func (*Query) GetOne

func (this *Query) GetOne(args ...interface{}) (err error)

func (*Query) Next

func (this *Query) Next() bool

func (*Query) Open

func (this *Query) Open(args ...interface{}) (err error)

func (*Query) SetSQL

func (this *Query) SetSQL(query string, args ...interface{}) *Query

type Transaction

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

func (*Transaction) Commit

func (this *Transaction) Commit() error

func (*Transaction) NewQuery

func (this *Transaction) NewQuery(args ...interface{}) *Query

func (*Transaction) Rollback

func (this *Transaction) Rollback() error

Jump to

Keyboard shortcuts

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