zdpgo_postgres

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 5 Imported by: 0

README

zdpgo_postgres

Golang操作PostgreSQL的基础组件

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CrudSql added in v1.0.2

type CrudSql interface {
	Add(sql string, args ...interface{}) int64                          // 添加数据
	Delete(table string, id int) bool                                   // 根据ID删除数据
	DeleteIds(table string, ids ...int) bool                            // 根据ID列表删除数据
	Update(sql string, args ...interface{}) bool                        // 根据ID修改数据
	Find(table string, columns []string, id int) *sql.Row               // 根据ID查询数据
	FindIds(table string, columns []string, ids []int) *sql.Rows        // 根据ID列表查询数据
	FindPages(table string, columns []string, page, size int) *sql.Rows // 根据分页查询数据
}

增删改查的SQL接口

type Postgres added in v1.0.2

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

PostgreSQL结构体

func New added in v1.0.2

func New(host string, port int, user, password, database, logPath string, debug bool) *Postgres

New 创建新的Postgres对象 @param host 主机地址 @param port 端口号 @param user 用户名 @param password 密码 @param database 数据库名称 @param logPath 日志存放路径 @param debug 是否为debug模式

func (*Postgres) Execute added in v1.0.2

func (p *Postgres) Execute(sql string, args ...interface{}) int64

Execute 执行增删改SQL语句

func (*Postgres) Find added in v1.0.2

func (p *Postgres) Find(sql string, args ...interface{}) pgx.Row

Find 从数据库中查询单条数据

func (*Postgres) FindMany added in v1.0.2

func (p *Postgres) FindMany(sql string, args ...interface{}) (rows pgx.Rows, err error)

FindMany 从数据库中查询多条数据

func (*Postgres) SetDebug added in v1.0.2

func (p *Postgres) SetDebug(debug bool)

设置debug模式

func (*Postgres) SetLogPath added in v1.0.2

func (p *Postgres) SetLogPath(logPath string)

设置日志文件路径

Directories

Path Synopsis
examples
z02_create_user command
z03_delete_user command
z04_update_user command
z05_find_user command

Jump to

Keyboard shortcuts

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