Polluter
The easiest solution to seed database with Go
Install / Use
/learn @romanyx/PolluterREADME
polluter
Mainly this package was created for testing purposes, to give the ability to seed a database with records from simple .yaml files. Polluter respects the order in files, so you can handle foreign_keys just by placing them in the right order.
Usage
package main
import "github.com/romanyx/polluter"
const input = `
roles:
- name: User
users:
- name: Roman
role_id: 1
`
func TestX(t *testing.T) {
db := prepareMySQL(t)
defer db.Close()
p := polluter.New(polluter.MySQLEngine(db))
if err := p.Pollute(strings.NewReader(input)); err != nil {
t.Fatalf("failed to pollute: %s", err)
}
....
}
Examples
See examples of usage with parallel testing.
Testing
Make shure to start docker before testing.
go test
Supported databases
- MySQL
- Postgres
- Redis
Contributing
Please feel free to submit issues, fork the repository and send pull requests!
Related Skills
xurl
343.1kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
notion
343.1kNotion API for creating and managing pages, databases, and blocks.
feishu-drive
343.1k|
things-mac
343.1kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
