idb

package
v0.0.0-...-2e4edee Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

数据库连接处理,根据配置文件进行。

提供的配置信息为*cpool.Section类型。 需要配置信息提供的配置项为:

type		# 数据库类型,目前只支持使用postgresql
server		# 数据库服务器的地址
port		# 数据库服务器的端口号
user		# 数据库访问用户名
passwd		# 数据库访问用户的密码
dbname		# 数据库名

目前只支持PostgreSQL连接。

Index

Constants

View Source
const (
	//数据库的类型
	DATABASE_TYPE_POSTGRESQL = iota
	DATABASE_TYPE_MYSQL
	DATABASE_TYPE_SQLITE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func NewDatabase

func NewDatabase(conf *cpool.Section, logs *ilogs.Logs) (db *DB, err error)

新建数据库连接。 此函数根据传入配置文件中关于数据库连接的信息进行配置,使用Golang自己的数据库接口,返回*sql.DB类型的数据库连接。 目前只处理针对PostgreSQL数据库的连接。

Jump to

Keyboard shortcuts

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