Mocks DB is a lightweight, mock MySQL server designed for testing and development. It accepts any standard MySQL connection and query, but instead of storing data, it generates realistic "junk" data on the fly based on your provided schema.
Perfect for performance testing, UI development, or any scenario where you need a database that acts like the real thing but populates itself.
- MySQL Protocol Support: Connect with any standard MySQL client (CLI, Workbench, generic libraries).
- Dynamic Data Generation: Uses Faker to generate realistic data based on column types.
- Schema Awareness: define your table structures via standard
CREATE TABLEstatements. - Configurable: Control row counts, limits, and random seeds.
- Zero Storage: No disk I/O for data, everything is generated in memory on demand.
pip install mocks-dbRun the server with a file:
mocks-db --schema schema.sql --port 3306Or pass the schema directly as a string:
mocks-db --schema-content "CREATE TABLE users (id INT, name VARCHAR(255));" --port 3306Connect with your favorite client:
mysql -h 127.0.0.1 -P 3306 -u rootRun queries:
SELECT * FROM users LIMIT 10;To develop and test locally without installing from a remote repository:
-
Clone the repo (if you haven't already).
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install dependencies and the package in editable mode:
pip install -e . -
Run the server:
mocks-db --schema-content "CREATE TABLE test (id INT);"Or run efficiently via python module:
python -m mocks_db.main --help
-
Install development dependencies and run tests:
This project uses
pyproject.tomlfor dependency management. You can install the package along with development dependencies (like pytest) using the[dev]extra:pip install -e ".[dev]"Or use the legacy requirements style:
pip install -r requirements-dev.txt
Then run tests:
pytest
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.