Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/viant/dsc
Datastore Connectivity in go
https://github.com/viant/dsc
Last synced: 6 days ago
JSON representation
Datastore Connectivity in go
- Host: GitHub
- URL: https://github.com/viant/dsc
- Owner: viant
- License: apache-2.0
- Created: 2016-06-13T20:18:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-05-25T20:01:58.000Z (7 months ago)
- Last Synced: 2024-07-31T20:50:02.257Z (4 months ago)
- Language: Go
- Homepage:
- Size: 364 KB
- Stars: 32
- Watchers: 17
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - dsc - Datastore connectivity for SQL, NoSQL, structured files. (Database Drivers / Interfaces to Multiple Backends)
- awesome-go-storage - dsc - Datastore connectivity for SQL, NoSQL, structured files. (Database Drivers)
- awesome-go - dsc - Datastore Connectivity in go - ★ 6 (Database Drivers)
- awesome-go-extra - dsc - 06-13T20:18:10Z|2022-02-14T19:53:33Z| (Generators / Interfaces to Multiple Backends)
- awesome-go-storage - dsc - Datastore connectivity for SQL, NoSQL, structured files. (Database Drivers)
README
# Datastore Connectivity (dsc)
[![Datastore Connectivity library for Go.](https://goreportcard.com/badge/github.com/viant/dsc)](https://goreportcard.com/report/github.com/viant/dsc)
[![GoDoc](https://godoc.org/github.com/viant/dsc?status.svg)](https://godoc.org/github.com/viant/dsc)This library is compatible with Go 1.10+
Please refer to [`CHANGELOG.md`](CHANGELOG.md) if you encounter breaking changes.
- [Motivation](#Motivation)
- [Usage](#Usage)
- [Prerequisites](#Prerequisites)
- [Installation](#Installation)
- [API Documentaion](#API-Documentation)
- [Tests](#Tests)
- [Examples](#Examples)
- [License](#License)
- [Credits and Acknowledgements](#Credits-and-Acknowledgements)## Motivation
This library was developed as part of dsunit (Datastore unit testibility library) to provide unified access to SQL, noSQL,
or any other store that deals with structured data in SQL-ish way.## Usage:
The following is a very simple example of CRUD operations with dsc
```go
package mainimport (
)func main() {
config := dsc.NewConfig("mysql", "[user]:[password]@[url]", "user:root,password:dev,url:tcp(127.0.0.1:3306)/mydb?parseTime=true")
factory := NewManagerFactory()
manager, err := factory.Create(config)
if err != nil {
panic(err.Error())
}// manager := factory.CreateFromURL("file:///etc/myapp/datastore.json")
interest := Interest{}
success, err:= manager.ReadSingle(&interest, "SELECT id, name, expiry, category FROM interests WHERE id = ?", []interface{}{id},nil)
if err != nil {
panic(err.Error())
}var interests = make([]Interest, 0)
err:= manager.ReadAll(&interests, "SELECT id, name, expiry, category FROM interests", nil ,nil)
if err != nil {
panic(err.Error())
}fmt.Printf("all interests: %v\n", interests)
interests = []Interest {
Interest{Name:"Abc", ExpiryTimeInSecond:3600, Category:"xyz"},
Interest{Name:"Def", ExpiryTimeInSecond:3600, Category:"xyz"},
Interest{Id:20, Name:"Ghi", ExpiryTimeInSecond:3600, Category:"xyz"},
}inserted, updated, err:= manager.PersistAll(&interests, "interests", nil)
if err != nil {
panic(err.Error())
}
deleted, err := manager.DeleteAll(&interests, "interests", nil)
if err != nil {
panic(err.Error())
}
fmt.Printf("Inserted %v, updated: %v, deleted: %v\n", inserted, updated, deleted)
}
```More examples illustrating the use of the API are located in the
[`examples`](examples) directory.Details about the API are available in the [`docs`](docs) directory.
[Go](http://golang.org) version v1.5+ is required.
To install the latest stable version of Go, visit
[http://golang.org/dl/](http://golang.org/dl/)Target
1. Install Go 1.5+ and setup your environment as [Documented](http://golang.org/doc/code.html#GOPATH) here.
2. Get the client in your ```GOPATH``` : ```go get github.com/viant/dsc```
* To update the client library: ```go get -u github.com/viant/dsc```### Some Hints:
* To run a go program directly: ```go run ```
* to build: ```go build -o ```## API Documentation
API documentation is available in the [`docs`](docs/README.md) directory.
## Tests
This library is packaged with a number of tests. Tests require Testify library.
Before running the tests, you need to update the dependencies:
$ go get .
To run all the test cases with race detection:
$ go test
A simple CRUD applications is provided in the [`examples`](examples) directory.
## GoCover
[![GoCover](http://gocover.io/github.com/viant/dsc)](http://gocover.io/github.com/viant/dsc)
The source code is made available under the terms of the Apache License, Version 2, as stated in the file `LICENSE`.
Individual files may be made available under their own specific license,
all compatible with Apache License, Version 2. Please see individual files for details.## Credits and Acknowledgements
**Library Author:** Adrian Witas
**Contributors:** Sudhakaran Dharmaraj