-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
ddaaf74
commit 638ef2e
Showing
9 changed files
with
197 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,78 @@ | ||
# PostgresConn | ||
# psqlconn | ||
|
||
![GitHub contributors](https://img.shields.io/github/contributors/sivaosorg/gocell) | ||
![GitHub followers](https://img.shields.io/github/followers/sivaosorg) | ||
![GitHub User's stars](https://img.shields.io/github/stars/pnguyen215) | ||
|
||
A Golang PostgreSQL connector library with comprehensive functionality, including database creation, batch execution, and transaction management. | ||
|
||
## Table of Contents | ||
|
||
- [psqlconn](#psqlconn) | ||
- [Table of Contents](#table-of-contents) | ||
- [Introduction](#introduction) | ||
- [Prerequisites](#prerequisites) | ||
- [Installation](#installation) | ||
- [Modules](#modules) | ||
- [Running Tests](#running-tests) | ||
- [Tidying up Modules](#tidying-up-modules) | ||
- [Upgrading Dependencies](#upgrading-dependencies) | ||
- [Cleaning Dependency Cache](#cleaning-dependency-cache) | ||
|
||
## Introduction | ||
|
||
Welcome to the Postgres Connector for Go repository! This library provides a robust set of features for interacting with PostgreSQL databases in your Go applications. It includes the ability to create new databases, execute batch operations, and manage transactions efficiently. | ||
|
||
## Prerequisites | ||
|
||
Golang version v1.20 | ||
|
||
## Installation | ||
|
||
- Latest version | ||
|
||
```bash | ||
go get -u github.com/sivaosorg/psqlconn@latest | ||
``` | ||
|
||
- Use a specific version (tag) | ||
|
||
```bash | ||
go get github.com/sivaosorg/psqlconn@v0.0.1 | ||
``` | ||
|
||
## Modules | ||
|
||
Explain how users can interact with the various modules. | ||
|
||
### Running Tests | ||
|
||
To run tests for all modules, use the following command: | ||
|
||
```bash | ||
make test | ||
``` | ||
|
||
### Tidying up Modules | ||
|
||
To tidy up the project's Go modules, use the following command: | ||
|
||
```bash | ||
make tidy | ||
``` | ||
|
||
### Upgrading Dependencies | ||
|
||
To upgrade project dependencies, use the following command: | ||
|
||
```bash | ||
make deps-upgrade | ||
``` | ||
|
||
### Cleaning Dependency Cache | ||
|
||
To clean the Go module cache, use the following command: | ||
|
||
```bash | ||
make deps-clean-cache | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package example | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/sivaosorg/govm/dbx" | ||
"github.com/sivaosorg/govm/logger" | ||
"github.com/sivaosorg/govm/postgres" | ||
"github.com/sivaosorg/psqlconn" | ||
) | ||
|
||
func createConn() (*psqlconn.Postgres, dbx.Dbx) { | ||
return psqlconn.NewClient(*postgres.GetPostgresConfigSample(). | ||
SetDebugMode(false). | ||
SetEnabled(true). | ||
SetPort(6666). | ||
SetUsername("tms_admin"). | ||
SetDatabase("db"). | ||
SetPassword("Usfy3siOO%fX")) | ||
} | ||
|
||
func TestConn(t *testing.T) { | ||
_, s := createConn() | ||
logger.Infof("Postgres connection status: %v", s) | ||
} | ||
|
||
func TestServiceTables(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
tables, err := svc.Tables() | ||
if err != nil { | ||
logger.Errorf("Fetching all tables got an error", err) | ||
return | ||
} | ||
logger.Infof("All tables: %v", tables) | ||
} | ||
|
||
func TestServiceFunctions(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
functions, err := svc.FunctionsDescriptor() | ||
if err != nil { | ||
logger.Errorf("Fetching all functions got an error", err) | ||
return | ||
} | ||
logger.Infof("All functions: %v", functions) | ||
} | ||
|
||
func TestServiceProduces(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
functions, err := svc.ProceduresDescriptor() | ||
if err != nil { | ||
logger.Errorf("Fetching all procedures got an error", err) | ||
return | ||
} | ||
logger.Infof("All procedures: %v", functions) | ||
} | ||
|
||
func TestServiceFunctionDescriptor(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
tables, err := svc.FunctionDescriptor("get_activelead_v7") | ||
if err != nil { | ||
logger.Errorf("Fetching function descriptor got an error", err) | ||
return | ||
} | ||
logger.Infof("Function descriptor: %v", tables) | ||
} | ||
|
||
func TestServiceFunctionTypeDescriptor(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
tables, err := svc.FunctionDDescriptor("get_activelead_v7") | ||
if err != nil { | ||
logger.Errorf("Fetching function descriptor got an error", err) | ||
return | ||
} | ||
logger.Infof("Function descriptor: %v", tables) | ||
} | ||
|
||
func TestServiceTableTypeDescriptor(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
desc, err := svc.TableDescriptor("or_user") | ||
if err != nil { | ||
logger.Errorf("Fetching table descriptor got an error", err) | ||
return | ||
} | ||
logger.Infof("Table descriptor: %v", desc) | ||
} | ||
|
||
func TestServiceTableDescriptor(t *testing.T) { | ||
p, _ := createConn() | ||
svc := psqlconn.NewPostgresService(p) | ||
desc, err := svc.TableInfo("or_user") | ||
if err != nil { | ||
logger.Errorf("Fetching table info got an error", err) | ||
return | ||
} | ||
logger.Infof("Table info: %v", desc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/sivaosorg/postgresconn | ||
module github.com/sivaosorg/psqlconn | ||
|
||
go 1.20 | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package postgresconn | ||
package psqlconn | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package psqlconn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package postgresconn | ||
package psqlconn | ||
|
||
import ( | ||
"github.com/jmoiron/sqlx" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package postgresconn | ||
package psqlconn | ||
|
||
import ( | ||
"fmt" | ||
|