postgres

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package postgres 提供 PostgreSQL 数据库驱动接入。

本包为可选驱动: 业务项目仅当 import 本包时才会拉取 gorm.io/driver/postgres 及其依赖, 未使用的驱动(mysql/sqlite 等)不会进入业务项目的依赖树。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgreSQL

type PostgreSQL struct {
	database.DatabasePool // 数据库连接池配置

	LoggerLevel string `yaml:"logger_level" toml:"logger_level" json:"logger_level" mapstructure:"logger_level"` // 日志级别: silent, warn, warning, info, error
	Host        string `yaml:"host" toml:"host" json:"host" mapstructure:"host"`                                 // 数据库主机
	Port        int    `yaml:"port" toml:"port" json:"port" mapstructure:"port"`                                 // 数据库端口
	User        string `yaml:"user" toml:"user" json:"user" mapstructure:"user"`                                 // 数据库用户名
	Password    string `yaml:"password" toml:"password" json:"password" mapstructure:"password"`                 // 数据库密码
	DB          string `yaml:"db" toml:"db" json:"db" mapstructure:"db"`                                         // 数据库名称
	SSLMode     string `yaml:"ssl_mode" toml:"ssl_mode" json:"ssl_mode" mapstructure:"ssl_mode"`                 // SSL 模式: disable, require, verify-ca, verify-full
	TimeZone    string `yaml:"time_zone" toml:"time_zone" json:"time_zone" mapstructure:"time_zone"`             // 时区: Asia/Shanghai
}

PostgreSQL 数据库配置

func (*PostgreSQL) Connect

func (p *PostgreSQL) Connect() error

Connect 连接数据库

func (*PostgreSQL) DSN

func (p *PostgreSQL) DSN() string

DSN 数据库连接字符串

Jump to

Keyboard shortcuts

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