Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects, and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Developer articles
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Small and medium teams
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
go-sdk
database
Repository navigation
Code
Pull requests
Actions
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
database
/
doc.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
30 lines (30 loc) · 1.17 KB
master
Breadcrumbs
database
/
doc.go
Copy path
Top
File metadata and controls
Code
Blame
30 lines (30 loc) · 1.17 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Package database 是个人使用的 Go 数据库基础类库,基于 GORM 统一 MySQL、
// PostgreSQL 和 SQLite 的初始化、日志、版本迁移、跨副本迁移锁、Redis
// 客户端与租约锁、JSON 字段和毫秒时间戳软删除行为。
//
// 根包本身不提供 API,主要能力位于以下子包:
//
// dbx 打开数据库、连接池配置、GORM 日志、错误翻译和软删除元数据
// dbx/migrate 数据库版本迁移、迁移记录表和多副本迁移锁
// dbx/mysql MySQL 与 MariaDB 驱动
// dbx/postgres PostgreSQL 驱动
// dbx/sqlite SQLite 驱动
// dbx/datatype JSON 字段等扩展数据类型
// rdx Redis 单机与 Sentinel 客户端
// rdx/lock Redis 持有者令牌租约锁
//
// 安装后按需空白导入驱动,并使用 dbx.Open 打开数据库:
//
// import (
// "github.com/go-sdk/database/dbx"
// _ "github.com/go-sdk/database/dbx/mysql"
// )
//
// db, err := dbx.Open("mysql", "user:password@tcp(localhost:3306)/app")
//
// 安装:
//
// go get github.com/go-sdk/database
//
// 迁移、连接池配置、软删除和真实数据库测试等详细说明见项目 README。
package database
You can’t perform that action at this time.