database

package
v0.0.0-...-e317c74 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	Db      *gorm.DB
	DbError error
}

Database 数据库连接

func NewMysql

func NewMysql(master []string, slave []string, port string, user string, pwd string, database string) *Database

NewMysql 实例化一个mysql连接

func NewPostgresSql

func NewPostgresSql(master []string, slave []string, port string, user string, pwd string, database string) *Database

NewPostgresSql 实例化一个postgres连接

func NewSqlite

func NewSqlite(file string) *Database

NewSqlite 实例化一个sqlite连接

func (*Database) BatchExecute

func (d *Database) BatchExecute(slice interface{}, batchSize int, fn func(batch interface{}) error) error

BatchExecute 批量执行

func (*Database) Close

func (d *Database) Close() error

Close 关闭底层数据库连接。

func (*Database) Transaction

func (d *Database) Transaction(fc func(tx *gorm.DB) error) error

Transaction 事务执行

Jump to

Keyboard shortcuts

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