https://github.com/donghquinn/gdct
go-database-client
https://github.com/donghquinn/gdct
client database go mariadb mysql postgres query
Last synced: 3 months ago
JSON representation
go-database-client
- Host: GitHub
- URL: https://github.com/donghquinn/gdct
- Owner: donghquinn
- License: mit
- Created: 2025-03-14T02:49:32.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-03-14T06:13:37.000Z (3 months ago)
- Last Synced: 2025-03-14T06:29:47.990Z (3 months ago)
- Topics: client, database, go, mariadb, mysql, postgres, query
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go-Database-Client
## Introduction
* It's Database Client Package## Dependencies
* It depends on postgres and mysql driver### Postgres
```zsh
go get -u github.com/lib/pq
```### Mariadb / Mysql
```zsh
go get -u github.com/go-sql-driver/mysql
```---
## Installation
```zsh
go get github.com/donghquinn/gdct
```---
## Usage
* Every Single Method will close connection after transaction commited.
* So you have to open connection again for every time.
* Postgres start with Pg and Mariadb start with Mr### Mariadb / mysql
```go
package mainimport "github.com/donghquinn/gdct"
func main() {
conn, _ := gdct.InitConnect("mariadb", gdct.DBConfig{
UserName: "test",
Password: "1234",
Host: "192.168.0.101",
Port: 123,
Database: "test_db",
MaxLifeTime: 600,
MaxIdleConns: 50,
MaxOpenConns: 10
})pingErr := conn.MrCheckConnection()
// ...
}
```### Postgres
* All the methods are started with 'pg'
* pgSelectSingle
* pgSelectMultiple```go
package mainimport "github.com/donghquinn/gdct"
func main() {
conn, _ := gdct.InitConnect("postgres", gdct.DBConfig{
UserName: "test",
Password: "1234",
Host: "192.168.0.101",
Port: 123,
Database: "test_db",
SslMode: "disable",
MaxLifeTime: 600,
MaxIdleConns: 50,
MaxOpenConns: 10
})pingErr := conn.PgCheckConnection()
// ...
}
```