sqlite

package
v2.0.15 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIndex

func AddIndex(indexName, tableName string, unique bool, cols ...string) (sql string, args []any)

func Delete

func Delete(table string, condition condition.Condition) (sql string, args []any)

func DropIndex

func DropIndex(indexName string) (sql string, args []any)

func Flag2Generator

func Flag2Generator(f *basis.Flag) (basis.Generator, error)

func Insert

func Insert(table string, columns basis.Columns, rows []basis.Row, ignore bool) (sql string, args []any)

func Pragma

func Pragma(key string, values ...any) (sql string, args []any)

func Replace

func Replace(table string, columns basis.Columns, rows []basis.Row) (sql string, args []any)

func ShowIndexs

func ShowIndexs(tableName string) (sql string, args []any)

func Update

func Update(table, setters string, condition condition.Condition) (sql string, args []any)

Types

type Db

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

func NewDb

func NewDb(opt Options) (sqlite *Db, err error)

func (*Db) FetchColumns

func (db *Db) FetchColumns(table string) (columns []basis.Column, err error)

func (*Db) LoadTableSchema

func (db *Db) LoadTableSchema(table string) (t *basis.Table, err error)

func (*Db) Options

func (db *Db) Options() Options

func (*Db) ShowCreateTable

func (db *Db) ShowCreateTable(table string) (tableSql string, err error)

func (*Db) ShowTables

func (db *Db) ShowTables(pattern string) (tables []string, err error)

type Options

type Options struct {
	DbName                string `json:"dbName" yaml:"dbName"`
	MaxIdleConns          int    `json:"maxIdleConns" yaml:"maxIdleConns"`
	MaxOpenConns          int    `json:"maxOpenConns" yaml:"maxOpenConns"`
	ConnMaxIdleTimeSecond int64  `json:"connMaxIdleTimeSecond" yaml:"connMaxIdleTimeSecond"`
	ConnMaxLifetimeSecond int64  `json:"connMaxLifetimeSecond" yaml:"connMaxLifetimeSecond"`
}

func DefaultOption

func DefaultOption() Options

func Flag2Options

func Flag2Options(f *basis.Flag) Options

func OptionsWithJson

func OptionsWithJson(conf string) (opt Options, err error)

func OptionsWithYaml

func OptionsWithYaml(conf string) (opt Options, err error)

func (*Options) ConnMaxIdleTime

func (o *Options) ConnMaxIdleTime() time.Duration

func (*Options) ConnMaxLifetime

func (o *Options) ConnMaxLifetime() time.Duration

func (*Options) Dsn

func (o *Options) Dsn() string

type Query

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

func AcquireQuery

func AcquireQuery() *Query

AcquireQuery 获取sqliteQuery对象

func (*Query) Avg

func (q *Query) Avg(field string) (sql string, args []any)

func (*Query) Close

func (q *Query) Close()

func (*Query) Count

func (q *Query) Count(field string) (sql string, args []any)

func (*Query) From

func (q *Query) From(table string) basis.Query

func (*Query) Group

func (q *Query) Group(fields ...string) basis.Query

func (*Query) HasFrom

func (q *Query) HasFrom() bool

func (*Query) Having

func (q *Query) Having(having string) basis.Query

func (*Query) IndexBy

func (q *Query) IndexBy(indexName string) *Query

func (*Query) Limit

func (q *Query) Limit(limit int64) basis.Query

func (*Query) Max

func (q *Query) Max(field string) (sql string, args []any)

func (*Query) Min

func (q *Query) Min(field string) (sql string, args []any)

func (*Query) Offset

func (q *Query) Offset(offset int64) basis.Query

func (*Query) Order

func (q *Query) Order(orders ...string) basis.Query

func (*Query) Select

func (q *Query) Select(columns ...string) basis.Query

func (*Query) Sql

func (q *Query) Sql() (sql string, args []any)

func (*Query) Sum

func (q *Query) Sum(field string) (sql string, args []any)

func (*Query) Where

func (q *Query) Where(condition condition.Condition) basis.Query

Jump to

Keyboard shortcuts

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