xorm: xorm.io/xorm/core Index | Files

package core

import "xorm.io/xorm/core"

Index

Package Files

db.go error.go interface.go rows.go scan.go stmt.go tx.go

Variables

var (
    // ErrNoMapPointer represents error when no map pointer
    ErrNoMapPointer = errors.New("mp should be a map's pointer")
    // ErrNoStructPointer represents error when no struct pointer
    ErrNoStructPointer = errors.New("mp should be a struct's pointer")
)
var (
    // DefaultCacheSize sets the default cache size
    DefaultCacheSize = 200
)

func MapToSlice Uses

func MapToSlice(query string, mp interface{}) (string, []interface{}, error)

func StructToSlice Uses

func StructToSlice(query string, st interface{}) (string, []interface{}, error)

type DB Uses

type DB struct {
    *sql.DB
    Mapper names.Mapper

    Logger log.ContextLogger
    // contains filtered or unexported fields
}

DB is a wrap of sql.DB with extra contents

func FromDB Uses

func FromDB(db *sql.DB) *DB

FromDB creates a DB from a sql.DB

func Open Uses

func Open(driverName, dataSourceName string) (*DB, error)

Open opens a database

func (*DB) Begin Uses

func (db *DB) Begin() (*Tx, error)

func (*DB) BeginTx Uses

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) ExecContext Uses

func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*DB) ExecMap Uses

func (db *DB) ExecMap(query string, mp interface{}) (sql.Result, error)

func (*DB) ExecMapContext Uses

func (db *DB) ExecMapContext(ctx context.Context, query string, mp interface{}) (sql.Result, error)

ExecMapContext exec map with context.Context insert into (name) values (?) insert into (name) values (?name)

func (*DB) ExecStruct Uses

func (db *DB) ExecStruct(query string, st interface{}) (sql.Result, error)

func (*DB) ExecStructContext Uses

func (db *DB) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error)

func (*DB) NeedLogSQL Uses

func (db *DB) NeedLogSQL(ctx context.Context) bool

NeedLogSQL returns true if need to log SQL

func (*DB) Prepare Uses

func (db *DB) Prepare(query string) (*Stmt, error)

func (*DB) PrepareContext Uses

func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)

func (*DB) Query Uses

func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

Query overwrites sql.DB.Query

func (*DB) QueryContext Uses

func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)

QueryContext overwrites sql.DB.QueryContext

func (*DB) QueryMap Uses

func (db *DB) QueryMap(query string, mp interface{}) (*Rows, error)

QueryMap executes query with parameters via map

func (*DB) QueryMapContext Uses

func (db *DB) QueryMapContext(ctx context.Context, query string, mp interface{}) (*Rows, error)

QueryMapContext executes query with parameters via map and context

func (*DB) QueryRow Uses

func (db *DB) QueryRow(query string, args ...interface{}) *Row

func (*DB) QueryRowContext Uses

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

func (*DB) QueryRowMap Uses

func (db *DB) QueryRowMap(query string, mp interface{}) *Row

func (*DB) QueryRowMapContext Uses

func (db *DB) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row

func (*DB) QueryRowStruct Uses

func (db *DB) QueryRowStruct(query string, st interface{}) *Row

func (*DB) QueryRowStructContext Uses

func (db *DB) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row

func (*DB) QueryStruct Uses

func (db *DB) QueryStruct(query string, st interface{}) (*Rows, error)

func (*DB) QueryStructContext Uses

func (db *DB) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error)

type EmptyScanner Uses

type EmptyScanner struct {
}

func (EmptyScanner) Scan Uses

func (EmptyScanner) Scan(src interface{}) error

type Executer Uses

type Executer interface {
    ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

Executer represents an interface to execute a SQL

type NullTime Uses

type NullTime time.Time

func (*NullTime) Scan Uses

func (ns *NullTime) Scan(value interface{}) error

func (NullTime) Value Uses

func (ns NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type QueryExecuter Uses

type QueryExecuter interface {
    Queryer
    Executer
}

QueryExecuter combines the Queryer and Executer

type Queryer Uses

type Queryer interface {
    QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)
}

Queryer represents an interface to query a SQL to get data from database

type Row Uses

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

func ErrorRow Uses

func ErrorRow(err error) *Row

ErrorRow return an error row

func NewRow Uses

func NewRow(rows *Rows, err error) *Row

NewRow from rows

func (*Row) Columns Uses

func (row *Row) Columns() ([]string, error)

func (*Row) Scan Uses

func (row *Row) Scan(dest ...interface{}) error

func (*Row) ScanMap Uses

func (row *Row) ScanMap(dest interface{}) error

scan data to a map's pointer

func (*Row) ScanSlice Uses

func (row *Row) ScanSlice(dest interface{}) error

scan data to a slice's pointer, slice's length should equal to columns' number

func (*Row) ScanStructByIndex Uses

func (row *Row) ScanStructByIndex(dest interface{}) error

func (*Row) ScanStructByName Uses

func (row *Row) ScanStructByName(dest interface{}) error

func (*Row) ToMapString Uses

func (row *Row) ToMapString() (map[string]string, error)

type Rows Uses

type Rows struct {
    *sql.Rows
    // contains filtered or unexported fields
}

func (*Rows) ScanMap Uses

func (rs *Rows) ScanMap(dest interface{}) error

scan data to a map's pointer

func (*Rows) ScanSlice Uses

func (rs *Rows) ScanSlice(dest interface{}) error

scan data to a slice's pointer, slice's length should equal to columns' number

func (*Rows) ScanStructByIndex Uses

func (rs *Rows) ScanStructByIndex(dest ...interface{}) error

scan data to a struct's pointer according field index

func (*Rows) ScanStructByName Uses

func (rs *Rows) ScanStructByName(dest interface{}) error

scan data to a struct's pointer according field name

func (*Rows) ToMapString Uses

func (rs *Rows) ToMapString() ([]map[string]string, error)

type Stmt Uses

type Stmt struct {
    *sql.Stmt
    // contains filtered or unexported fields
}

Stmt reprents a stmt objects

func (*Stmt) ExecContext Uses

func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)

func (*Stmt) ExecMap Uses

func (s *Stmt) ExecMap(mp interface{}) (sql.Result, error)

func (*Stmt) ExecMapContext Uses

func (s *Stmt) ExecMapContext(ctx context.Context, mp interface{}) (sql.Result, error)

func (*Stmt) ExecStruct Uses

func (s *Stmt) ExecStruct(st interface{}) (sql.Result, error)

func (*Stmt) ExecStructContext Uses

func (s *Stmt) ExecStructContext(ctx context.Context, st interface{}) (sql.Result, error)

func (*Stmt) Query Uses

func (s *Stmt) Query(args ...interface{}) (*Rows, error)

func (*Stmt) QueryContext Uses

func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, error)

func (*Stmt) QueryMap Uses

func (s *Stmt) QueryMap(mp interface{}) (*Rows, error)

func (*Stmt) QueryMapContext Uses

func (s *Stmt) QueryMapContext(ctx context.Context, mp interface{}) (*Rows, error)

func (*Stmt) QueryRow Uses

func (s *Stmt) QueryRow(args ...interface{}) *Row

func (*Stmt) QueryRowContext Uses

func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *Row

func (*Stmt) QueryRowMap Uses

func (s *Stmt) QueryRowMap(mp interface{}) *Row

func (*Stmt) QueryRowMapContext Uses

func (s *Stmt) QueryRowMapContext(ctx context.Context, mp interface{}) *Row

func (*Stmt) QueryRowStruct Uses

func (s *Stmt) QueryRowStruct(st interface{}) *Row

func (*Stmt) QueryRowStructContext Uses

func (s *Stmt) QueryRowStructContext(ctx context.Context, st interface{}) *Row

func (*Stmt) QueryStruct Uses

func (s *Stmt) QueryStruct(st interface{}) (*Rows, error)

func (*Stmt) QueryStructContext Uses

func (s *Stmt) QueryStructContext(ctx context.Context, st interface{}) (*Rows, error)

type Tx Uses

type Tx struct {
    *sql.Tx
    // contains filtered or unexported fields
}

Tx represents a transaction

func (*Tx) ExecContext Uses

func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Tx) ExecMap Uses

func (tx *Tx) ExecMap(query string, mp interface{}) (sql.Result, error)

func (*Tx) ExecMapContext Uses

func (tx *Tx) ExecMapContext(ctx context.Context, query string, mp interface{}) (sql.Result, error)

func (*Tx) ExecStruct Uses

func (tx *Tx) ExecStruct(query string, st interface{}) (sql.Result, error)

func (*Tx) ExecStructContext Uses

func (tx *Tx) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error)

func (*Tx) Prepare Uses

func (tx *Tx) Prepare(query string) (*Stmt, error)

func (*Tx) PrepareContext Uses

func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error)

func (*Tx) Query Uses

func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error)

func (*Tx) QueryContext Uses

func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)

func (*Tx) QueryMap Uses

func (tx *Tx) QueryMap(query string, mp interface{}) (*Rows, error)

func (*Tx) QueryMapContext Uses

func (tx *Tx) QueryMapContext(ctx context.Context, query string, mp interface{}) (*Rows, error)

func (*Tx) QueryRow Uses

func (tx *Tx) QueryRow(query string, args ...interface{}) *Row

func (*Tx) QueryRowContext Uses

func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

func (*Tx) QueryRowMap Uses

func (tx *Tx) QueryRowMap(query string, mp interface{}) *Row

func (*Tx) QueryRowMapContext Uses

func (tx *Tx) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row

func (*Tx) QueryRowStruct Uses

func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row

func (*Tx) QueryRowStructContext Uses

func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row

func (*Tx) QueryStruct Uses

func (tx *Tx) QueryStruct(query string, st interface{}) (*Rows, error)

func (*Tx) QueryStructContext Uses

func (tx *Tx) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error)

func (*Tx) Stmt Uses

func (tx *Tx) Stmt(stmt *Stmt) *Stmt

func (*Tx) StmtContext Uses

func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt

Package core imports 11 packages (graph) and is imported by 4 packages. Updated 2020-04-08. Refresh now. Tools for package owners.