data

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package data 数据库/数据处理相关工具

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2str added in v1.1.6

func Bytes2str(b []byte) string

Bytes2str Fast convert

func DownloadTo added in v1.1.6

func DownloadTo(url, file string) error

func Max added in v1.1.7

func Max(a, b int) int

min 返回两数最大值,该函数将被内联

func Min added in v1.1.7

func Min(a, b int) int

min 返回两数最小值,该函数将被内联

func Str2bytes added in v1.1.6

func Str2bytes(s string) []byte

Str2bytes Fast convert

Types

type Sqlite

type Sqlite struct {
	DB     *sql.DB
	DBPath string
}

Sqlite 数据库对象

func (*Sqlite) Count

func (db *Sqlite) Count(table string) (num int, err error)

Count 查询数据库行数 返回行数以及错误

func (*Sqlite) Create

func (db *Sqlite) Create(table string, objptr interface{}) (err error)

Create 生成数据库 默认结构体的第一个元素为主键 返回错误

func (*Sqlite) Del

func (db *Sqlite) Del(table string, condition string) (err error)

Del 删除数据库 condition 可为"WHERE id = 0" 返回错误

func (*Sqlite) Find

func (db *Sqlite) Find(table string, objptr interface{}, condition string) (err error)

Find 查询数据库 condition 可为"WHERE id = 0" 默认字段与结构体元素顺序一致 返回错误

func (*Sqlite) Insert

func (db *Sqlite) Insert(table string, objptr interface{}) (err error)

Insert 插入数据集 默认结构体的第一个元素为主键 返回错误

func (*Sqlite) ListTables

func (db *Sqlite) ListTables() (s []string, err error)

ListTables 列出所有表名 返回所有表名+错误

Jump to

Keyboard shortcuts

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