sqldb

package
v0.0.0-...-278ce41 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ConnStrWithMySQL = "root:123456@tcp(127.0.0.1:3326)/crawler?charset=utf8m4"
)

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)

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        []any   // 数据
	DataCount   int     // 插入数据的量
	AutoKey     bool
}

Jump to

Keyboard shortcuts

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