Skip to content

Commit 638ef2e

Browse files
committed
🔇 silent changes: updated codebase #4 #2
1 parent ddaaf74 commit 638ef2e

9 files changed

Lines changed: 197 additions & 19 deletions

File tree

.github/workflows/go.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@ name: Go
55

66
on:
77
push:
8-
branches: [ "master" ]
8+
branches: ["master"]
99
tags:
1010
- "v*"
1111
pull_request:
12-
branches: [ "master" ]
12+
branches: ["master"]
1313

1414
jobs:
15-
1615
build:
1716
runs-on: ubuntu-latest
1817
steps:
19-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v3
2019

21-
- name: Set up Go
22-
uses: actions/setup-go@v3
23-
with:
24-
go-version: 1.19
20+
- name: Set up Go
21+
uses: actions/setup-go@v3
22+
with:
23+
go-version: 1.19
2524

26-
- name: Build
27-
run: go build -v ./...
25+
- name: Build
26+
run: go build -v ./...
2827

29-
- name: Test
30-
run: go test -v ./...
28+
# - name: Test
29+
# run: go test -v ./...
3130

3231
create-release:
3332
runs-on: ubuntu-latest
@@ -57,4 +56,4 @@ jobs:
5756
draft: false
5857
prerelease: false
5958
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
# PostgresConn
1+
# psqlconn
2+
3+
![GitHub contributors](https://img.shields.io/github/contributors/sivaosorg/gocell)
4+
![GitHub followers](https://img.shields.io/github/followers/sivaosorg)
5+
![GitHub User's stars](https://img.shields.io/github/stars/pnguyen215)
6+
7+
A Golang PostgreSQL connector library with comprehensive functionality, including database creation, batch execution, and transaction management.
8+
9+
## Table of Contents
10+
11+
- [psqlconn](#psqlconn)
12+
- [Table of Contents](#table-of-contents)
13+
- [Introduction](#introduction)
14+
- [Prerequisites](#prerequisites)
15+
- [Installation](#installation)
16+
- [Modules](#modules)
17+
- [Running Tests](#running-tests)
18+
- [Tidying up Modules](#tidying-up-modules)
19+
- [Upgrading Dependencies](#upgrading-dependencies)
20+
- [Cleaning Dependency Cache](#cleaning-dependency-cache)
21+
22+
## Introduction
23+
24+
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.
25+
26+
## Prerequisites
27+
28+
Golang version v1.20
29+
30+
## Installation
31+
32+
- Latest version
33+
34+
```bash
35+
go get -u github.com/sivaosorg/psqlconn@latest
36+
```
37+
38+
- Use a specific version (tag)
39+
40+
```bash
41+
go get github.com/sivaosorg/psqlconn@v0.0.1
42+
```
43+
44+
## Modules
45+
46+
Explain how users can interact with the various modules.
47+
48+
### Running Tests
49+
50+
To run tests for all modules, use the following command:
51+
52+
```bash
53+
make test
54+
```
55+
56+
### Tidying up Modules
57+
58+
To tidy up the project's Go modules, use the following command:
59+
60+
```bash
61+
make tidy
62+
```
63+
64+
### Upgrading Dependencies
65+
66+
To upgrade project dependencies, use the following command:
67+
68+
```bash
69+
make deps-upgrade
70+
```
71+
72+
### Cleaning Dependency Cache
73+
74+
To clean the Go module cache, use the following command:
75+
76+
```bash
77+
make deps-clean-cache
78+
```

example/psqlconn_test.go

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package example
2+
3+
import (
4+
"testing"
5+
6+
"github.com/sivaosorg/govm/dbx"
7+
"github.com/sivaosorg/govm/logger"
8+
"github.com/sivaosorg/govm/postgres"
9+
"github.com/sivaosorg/psqlconn"
10+
)
11+
12+
func createConn() (*psqlconn.Postgres, dbx.Dbx) {
13+
return psqlconn.NewClient(*postgres.GetPostgresConfigSample().
14+
SetDebugMode(false).
15+
SetEnabled(true).
16+
SetPort(6666).
17+
SetUsername("tms_admin").
18+
SetDatabase("db").
19+
SetPassword("Usfy3siOO%fX"))
20+
}
21+
22+
func TestConn(t *testing.T) {
23+
_, s := createConn()
24+
logger.Infof("Postgres connection status: %v", s)
25+
}
26+
27+
func TestServiceTables(t *testing.T) {
28+
p, _ := createConn()
29+
svc := psqlconn.NewPostgresService(p)
30+
tables, err := svc.Tables()
31+
if err != nil {
32+
logger.Errorf("Fetching all tables got an error", err)
33+
return
34+
}
35+
logger.Infof("All tables: %v", tables)
36+
}
37+
38+
func TestServiceFunctions(t *testing.T) {
39+
p, _ := createConn()
40+
svc := psqlconn.NewPostgresService(p)
41+
functions, err := svc.FunctionsDescriptor()
42+
if err != nil {
43+
logger.Errorf("Fetching all functions got an error", err)
44+
return
45+
}
46+
logger.Infof("All functions: %v", functions)
47+
}
48+
49+
func TestServiceProduces(t *testing.T) {
50+
p, _ := createConn()
51+
svc := psqlconn.NewPostgresService(p)
52+
functions, err := svc.ProceduresDescriptor()
53+
if err != nil {
54+
logger.Errorf("Fetching all procedures got an error", err)
55+
return
56+
}
57+
logger.Infof("All procedures: %v", functions)
58+
}
59+
60+
func TestServiceFunctionDescriptor(t *testing.T) {
61+
p, _ := createConn()
62+
svc := psqlconn.NewPostgresService(p)
63+
tables, err := svc.FunctionDescriptor("get_activelead_v7")
64+
if err != nil {
65+
logger.Errorf("Fetching function descriptor got an error", err)
66+
return
67+
}
68+
logger.Infof("Function descriptor: %v", tables)
69+
}
70+
71+
func TestServiceFunctionTypeDescriptor(t *testing.T) {
72+
p, _ := createConn()
73+
svc := psqlconn.NewPostgresService(p)
74+
tables, err := svc.FunctionDDescriptor("get_activelead_v7")
75+
if err != nil {
76+
logger.Errorf("Fetching function descriptor got an error", err)
77+
return
78+
}
79+
logger.Infof("Function descriptor: %v", tables)
80+
}
81+
82+
func TestServiceTableTypeDescriptor(t *testing.T) {
83+
p, _ := createConn()
84+
svc := psqlconn.NewPostgresService(p)
85+
desc, err := svc.TableDescriptor("or_user")
86+
if err != nil {
87+
logger.Errorf("Fetching table descriptor got an error", err)
88+
return
89+
}
90+
logger.Infof("Table descriptor: %v", desc)
91+
}
92+
93+
func TestServiceTableDescriptor(t *testing.T) {
94+
p, _ := createConn()
95+
svc := psqlconn.NewPostgresService(p)
96+
desc, err := svc.TableInfo("or_user")
97+
if err != nil {
98+
logger.Errorf("Fetching table info got an error", err)
99+
return
100+
}
101+
logger.Infof("Table info: %v", desc)
102+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/sivaosorg/postgresconn
1+
module github.com/sivaosorg/psqlconn
22

33
go 1.20
44

postgresconn_config.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

postgresconn.go renamed to psqlconn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package postgresconn
1+
package psqlconn
22

33
import (
44
"context"

psqlconn_config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package psqlconn
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package postgresconn
1+
package psqlconn
22

33
import (
44
"github.com/jmoiron/sqlx"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package postgresconn
1+
package psqlconn
22

33
import (
44
"fmt"

0 commit comments

Comments
 (0)