An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# go-mysql
An easy to use Mockable db interface for mysql

[![Go Report Card](https://goreportcard.com/badge/github.com/GolangToolKits/go-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()

```