db

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 6 Imported by: 0

README

db

基于SQLite3,对存取过程的抽象封装。

Documentation

Overview

Package db to manage database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB 定制的sql数据库

func (*DB) GetRows

func (db *DB) GetRows(queryStatement string, StructPtr interface{}) ([]interface{}, error)

GetRows 描述了从数据库中查询的过程

func (*DB) GetValues

func (db *DB) GetValues(statement string, dest ...interface{}) error

GetValues 获取查询语句的多个值 在dest存放变量的指针 NOTICE: dest中变量的指针的顺序,需要与statement中查询的一样

func (*DB) Insert

func (db *DB) Insert(insertStatement string, data interface{}) error

Insert 描述了向DB内插入数据的过程

func (*DB) Name

func (db *DB) Name() string

Name 返回数据库的名称,也是数据库的存放地址

type DBer

type DBer interface {
	Name() string
	Insert(statement string, data interface{}) error
	GetRows(statement string, structPtr interface{}) ([]interface{}, error)
	GetValues(statement string, dest ...interface{}) error
}

DBer 是定制数据库的接口

func Connect

func Connect(filename string, createStatement string) (DBer, error)

Connect 返回一个数据库对象

Jump to

Keyboard shortcuts

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