https://github.com/GolangToolKits/go-mysql
A simple mockable mysql db interface
https://github.com/GolangToolKits/go-mysql
database go golang mysql mysql-database
Last synced: 9 months ago
JSON representation
A simple mockable mysql db interface
- Host: GitHub
- URL: https://github.com/GolangToolKits/go-mysql
- Owner: GolangToolKits
- License: mit
- Created: 2023-02-02T22:08:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-01T17:18:11.000Z (over 3 years ago)
- Last Synced: 2025-01-24T05:12:01.757Z (over 1 year ago)
- Topics: database, go, golang, mysql, mysql-database
- Language: Go
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mysql
An easy to use Mockable db interface for mysql
[](https://goreportcard.com/report/github.com/GolangToolKits/go-mysql)
```go
mm := &MyDB{
Host: "localhost:3306",
User: "test",
Password: "test",
Database: "test",
}
m := mm.New()
m.Connect()
m.Insert(query, args...)
m.Update(query, args...)
m.Get(query, args...)
m.GetList(query, args...)
m.Delete(query, args...)
```
## Also Supports Transactions
```go
mm := &MyDB{
Host: "localhost:3306",
User: "test",
Password: "test",
Database: "test",
}
m := mm.New()
m.Connect()
tr := m.BeginTransaction()
tr.Insert(query, args...)
tr.Update(query, args...)
tr.Get(query, args...)
tr.GetList(query, args...)
tr.Delete(query, args...)
tr.Commit()
//Or
tr.Rollback()
```