Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elasticrash/spawnflake
Spawnflake is a schema agnostic, random and/or patterns based data generator, for MySQL databases.
https://github.com/elasticrash/spawnflake
database database-testing fake-data-generator integration-testing
Last synced: 2 months ago
JSON representation
Spawnflake is a schema agnostic, random and/or patterns based data generator, for MySQL databases.
- Host: GitHub
- URL: https://github.com/elasticrash/spawnflake
- Owner: elasticrash
- License: mit
- Created: 2021-05-02T00:11:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-04-03T10:25:13.000Z (10 months ago)
- Last Synced: 2024-10-13T23:38:02.204Z (3 months ago)
- Topics: database, database-testing, fake-data-generator, integration-testing
- Language: Rust
- Homepage: https://discord.gg/khfC4NBcnX
- Size: 168 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# ![a pixel fish](./assets/logo.png "fish") Spawnflake [![Rust](https://github.com/elasticrash/spawnflake/actions/workflows/rust.yml/badge.svg)](https://github.com/elasticrash/spawnflake/actions/workflows/rust.yml)
Spawnflake is a schema agnostic, random and/or patterns based data generator, for MySQL databases.
## what's new
See [CHANGELOG](CHANGELOG.md) for updates and new features.## usage
This library works by providing a configuration file (config.json). The configuration is divided into two sections.
### connection properties (mandatory)
```json
"mysql_configuration": {
"address": "localhost",
"port": 3306,
"user": "local",
"password": "password",
"schema": "test"
}
```
### type patterns (optional)
```json
"types": {
"string": [
{
"name": "column_name",
"rules": []
}
],
"integer": [
{
"name": "column_name",
"rules":[]
}
],
"float": [
{
"name": "column_name",
"rules":[]
}
]
}
```
### Rules
* Rules for numeric types and dates just desired ranges (from, to). **Important!!** the small values need to be first in the lists.
* Rules for strings are combinatinatory, you provide collections that are mixed and matched.
i.e.```json
"rules": [
[
"Jo",
"Ni",
"Ste",
"Da",
"Sco",
"Ma"
],
[
"ve",
"vi",
"pha",
"ro",
"na",
"ri"
],
[
"n",
"ck",
"tt",
"d",
"than",
"na"
]
]
```
This could create real names like `David` but also complete random combinations like `Jophack`## known limitations
* When handling cyclic dependencies, keys are not currently updated retrospectively. This feature is planned for a future version
* If a foreign key is unique, fewer records will be inserted into that table. Unique foreign key values are not supported yet.
* In certain cases, number validation in the configuration is not performed, records assosiated with problematic tables cloud be
* skipped
* panic
* use default values
depending on a case by case basis.## support
### Database support
#### MySQL
* supported data types and generators:| Datastore | Data type | Random | Pattern |
| ----------- | ----------- |-----------| ----------- |
| Mysql | varchar | ✔️ | ✔️ |
| Mysql | int | ✔️ | ✔️ |
| Mysql | unsigned int | ✔️ | ✔️ |
| Mysql | smallint | ✔️ | ✔️ |
| Mysql | unsigned smallint | ✔️ | ✔️ |
| Mysql | tinyint/unsigned tinyint | ✔️ | ✔️ |
| Mysql | mediumint | ✔️ | ✔️ |
| Mysql | bigint | ✔️ | ✔️ |
| Mysql | unsigned bigint | ✔️ | ✔️ |
| Mysql | decimal | ✔️ | ✔️ |
| Mysql | float | ✔️ | ✔️ |
| Mysql | double | ✔️ | ✔️ |
| Mysql | bit | ✔️ | ❌ |
| Mysql | time | ✔️ | ✔️ |
| Mysql | timestamp | ✔️ | ✔️ |
| Mysql | date | ✔️ | ✔️ |
| Mysql | year | ✔️ | ❌ |
| Mysql | char | ✔️ | ❌ |
| Mysql | binary | ✔️ | ❌ |
| Mysql | text | ✔️ | ❌ |
| Mysql | longtext | ✔️ | ❌ |
| Mysql | blob/longblob | ✔️ | ❌ |
| Mysql | enum | ❌ | ✔️ |## CLI
The main project in this repository is a library, but there is also a [CLI version](https://crates.io/crates/spawnflake-cli) available published in crates.io.
The code for the CLI is available at `./cli`. Check [README](cli/readme.md) for usage and more information.## Running the example
Running the example requires running `docker-compose` inside the `test` folder. Make sure you have
* Docker
* An SQL client/ or a way to access the MySQL cli to view the generated recordsTo run the example execute
```bash
cargo run --example generate_mysql
```## Contributing
You are more than welcome. All you need to do is a pull request