Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rosspatil/sql-db-mocking
This repository demonstrate a library for sql to connect master and slave node with 100% test coverage.
https://github.com/rosspatil/sql-db-mocking
golang golang-library golang-package golang-testing mocking mydb sql sql-mocking
Last synced: 3 days ago
JSON representation
This repository demonstrate a library for sql to connect master and slave node with 100% test coverage.
- Host: GitHub
- URL: https://github.com/rosspatil/sql-db-mocking
- Owner: rosspatil
- Created: 2020-05-13T05:29:54.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-18T18:58:08.000Z (almost 3 years ago)
- Last Synced: 2024-06-21T17:02:50.601Z (5 months ago)
- Topics: golang, golang-library, golang-package, golang-testing, mocking, mydb, sql, sql-mocking
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MYDBConnect with one master DB and multiple read replicas
MYDB is a GO package that provides an automatic route read-only queries to read replicas, and all other queries to the master DB (see diagram below), without the user having to be aware of it.
![image.png](./image.png)
This package is very similiar to package `database/sql`.
Getting Started
===============## Installing
To start using mydb, install Go and run `go get`:
```sh
go get -u github.com/rosspatil/sql-db-mocking
```This will retrieve the library.
## Get the instance and start using it
Get the instance of DB Object and perform generic sql operations. You have to provide
one master db instance and atleast one replica instance```go
func New(master *sql.DB, readreplicas ...*sql.DB) (*DB, error)
```