sqlite

package module
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 16 Imported by: 1

README

cool-admin-go sqlite 驱动包

扩展了 GoFrame 的 sqlite 包,集成了 gorm 相关功能.

使用方法

引入规则应早于 modules相关引入,建议在 main.go 中进行引入。

import (
    _ "github.com/cool-team-official/cool-admin-go/contrib/drivers/sqlite"

    // 换行然后再入模块包,防止编辑器自动排序导致引入顺序错乱
    _ "github.com/cool-team-official/cool-admin-go/modules/base"

)

配置

database:
  default:
    type: "sqlite" # 数据库类型
    name: "cool.sqlite" # 数据库名称,对于sqlite来说就是数据库文件名
    extra: busy_timeout=5000 # 扩展参数 如 busy_timeout=5000&journal_mode=ALL
    createdAt: "createTime" # 创建时间字段名称
    updatedAt: "updateTime" # 更新时间字段名称
    debug: true # 开启调试模式,启用后将在控制台打印相关sql语句

Documentation

Overview

Package sqlite implements gdb.Driver, which supports operations for database SQLite.

Note: 1. It needs manually import: _ "github.com/glebarez/go-sqlite" 2. It does not support Save/Replace features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() gdb.Driver

New create and returns a driver that implements gdb.Driver, which supports operations for SQLite.

func NewSqlite added in v0.0.25

func NewSqlite() cooldb.Driver

Types

type Driver added in v0.0.25

type Driver struct {
	*gdb.Core
}

Driver is the driver for sqlite database.

func (*Driver) DoFilter added in v0.0.25

func (d *Driver) DoFilter(ctx context.Context, link gdb.Link, sql string, args []interface{}) (newSql string, newArgs []interface{}, err error)

DoFilter deals with the sql string before commits it to underlying sql driver.

func (*Driver) DoInsert added in v0.0.25

func (d *Driver) DoInsert(
	ctx context.Context, link gdb.Link, table string, list gdb.List, option gdb.DoInsertOption,
) (result sql.Result, err error)

DoInsert is not supported in sqlite.

func (*Driver) GetChars added in v0.0.25

func (d *Driver) GetChars() (charLeft string, charRight string)

GetChars returns the security char for this type of database.

func (*Driver) New added in v0.0.25

func (d *Driver) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error)

New creates and returns a database object for sqlite. It implements the interface of gdb.Driver for extra database driver installation.

func (*Driver) Open added in v0.0.25

func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error)

Open creates and returns a underlying sql.DB object for sqlite. https://github.com/glebarez/go-sqlite

func (*Driver) TableFields added in v0.0.25

func (d *Driver) TableFields(
	ctx context.Context, table string, schema ...string,
) (fields map[string]*gdb.TableField, err error)

TableFields retrieves and returns the fields' information of specified table of current schema.

Also see DriverMysql.TableFields.

func (*Driver) Tables added in v0.0.25

func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string, err error)

Tables retrieves and returns the tables of current schema. It's mainly used in cli tool chain for automatically generating the models.

type DriverSqlite

type DriverSqlite struct {
}

func (*DriverSqlite) GetConn

func (d *DriverSqlite) GetConn(config *gdb.ConfigNode) (db *gorm.DB, err error)

Jump to

Keyboard shortcuts

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