xormdb

package
v0.0.0-...-6dbb570 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(conf *Config) (*xorm.Engine, error)

初始化 xorm 引擎 sqlite3 sync2 时,xorm tag 中不能使用 comment(”) 调用 InitSB 时,需在调用源码文件中 import 对应的数据库,例如:import _ "github.com/mattn/go-sqlite3"

Types

type Config

type Config struct {
	DriverName     string // 必填
	DataSourceName string // 必填

	MaxOpenConns    int           // 设置最大打开连接数
	MaxIdleConns    int           // 设置数据库最大闲置连接数
	ConnMaxLifetime time.Duration // 设置数据库可以重用连接的最长时间

	NameMapper      names.Mapper // 指定使用的命名映射策略
	CacheMapper     bool         //是否启用名称映射缓存
	TableNamePrefix string       // 表名称前缀
	TableNameSuffix string       // 表名称后缀

	CacheQuery        bool // 是否启用查询缓存
	CacheQueryMaxSize int  // 最少 defaultCacheQuerySize 条缓存

	Sync       bool          // 是否启用同步
	SyncModels []interface{} // 那些数据结构要同步到表结构

	ShowSQL  bool         // 是否打印 sql 语句
	LogLevel log.LogLevel // LOG_DEBUG LOG_INFO LOG_WARNING LOG_ERR LOG_OFF LOG_UNKNOWN
}

Jump to

Keyboard shortcuts

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