https://github.com/gosuit/pg
PostgreSQL client
https://github.com/gosuit/pg
golang pgx postgres
Last synced: 10 months ago
JSON representation
PostgreSQL client
- Host: GitHub
- URL: https://github.com/gosuit/pg
- Owner: gosuit
- License: mit
- Created: 2025-01-30T08:28:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-20T12:57:31.000Z (10 months ago)
- Last Synced: 2025-08-20T13:27:38.502Z (10 months ago)
- Topics: golang, pgx, postgres
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PG
pg is a wrapper around the pgx library for PostgreSQL in Go. It simplifies the process of connecting to a PostgreSQL database, managing migrations, and other. This library provides a clean interface for database operations while leveraging the performance and features of pgx.
## Installation
```zsh
go get github.com/gosuit/pg
```
## Features
• Connection Management: Easily establish connections to PostgreSQL databases using configurable parameters.
• Migration Support: Automatically run database migrations using the goose migration tool.
• Other: Register custom PostgreSQL types with your database connection.
• Mocking: You can create mock client with mock pgx pool
## Usage
```golang
package main
import (
"context"
"log"
"github.com/gosuit/pg"
)
func main() {
ctx := context.Background()
cfg := &pg.Config{
Host: "localhost",
Port: 5432,
DBName: "your_database",
Username: "your_username",
Password: "your_password",
SSLMode: "disable",
MigrationsRun: true,
MigrationsPath: "./migrations",
}
client, err := pg.New(ctx, cfg)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
err = client.RegisterTypes([]string{"custom_type"})
if err != nil {
log.Fatalf("failed to register types: %v", err)
}
// Use client for database operations...
// Access underlying pgxpool
pool := client.ToPgx()
// Use pool...
}
```
## Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any enhancements or bug fixes.
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.