sqldb

package
v0.0.0-...-caa0154 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBer

type DBer interface {
	CreateTable(t TableData) error
	Insert(t TableData) error
}

type Field

type Field struct {
	Title string
	Type  string
}

type Option

type Option func(opts *options)

Option 选项模式,可以设置默认值

func WithConnUrl

func WithConnUrl(sqlURL string) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

type Sqldb

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

func New

func New(opts ...Option) (*Sqldb, error)

func (*Sqldb) CreateTable

func (d *Sqldb) CreateTable(t TableData) error

func (*Sqldb) DropTable

func (d *Sqldb) DropTable(t TableData) error

func (*Sqldb) Insert

func (d *Sqldb) Insert(t TableData) error

func (*Sqldb) OpenDB

func (d *Sqldb) OpenDB() error

type TableData

type TableData struct {
	TableName   string
	ColumnNames []Field       // 标题字段
	Args        []interface{} // 数据
	DataCount   int           // 插入数据的数量
	AutoKey     bool
}

Jump to

Keyboard shortcuts

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