Metadata-Version: 2.4
Name: mocks-db
Version: 0.1.0
Summary: A mock MySQL server that generates junk data based on your schema.
Author-email: Pratyush <pratyush@example.com>
License: MIT License
        
        Copyright (c) 2024 Pratyush
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/pratyush/mocks-db
Project-URL: Bug Tracker, https://github.com/pratyush/mocks-db/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mysql-mimic>=2.3.0
Requires-Dist: faker>=23.0.0
Requires-Dist: click>=8.1.0
Requires-Dist: sqlglot>=20.0.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# Mocks DB

![License](https://img.shields.io/github/license/pratyush/mocks-db)
![Python](https://img.shields.io/badge/python-3.9%2B-blue)

**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.

## Features

- **MySQL Protocol Support**: Connect with any standard MySQL client (CLI, Workbench, generic libraries).
- **Dynamic Data Generation**: Uses [Faker](https://github.com/joke2k/faker) to generate realistic data based on column types.
- **Schema Awareness**: define your table structures via standard `CREATE TABLE` statements.
- **Configurable**: Control row counts, limits, and random seeds.
- **Zero Storage**: No disk I/O for data, everything is generated in memory on demand.

## Installation

```bash
pip install mocks-db
```

## Usage

Run the server with a file:
```bash
mocks-db --schema schema.sql --port 3306
```

Or pass the schema directly as a string:
```bash
mocks-db --schema-content "CREATE TABLE users (id INT, name VARCHAR(255));" --port 3306
```

Connect with your favorite client:

```bash
mysql -h 127.0.0.1 -P 3306 -u root
```

Run queries:

```sql
SELECT * FROM users LIMIT 10;
```

## Development

To develop and test locally without installing from a remote repository:

1.  Clone the repo (if you haven't already).
2.  Create a virtual environment:
    ```bash
    python3 -m venv venv
    source venv/bin/activate
    ```
3.  Install dependencies and the package in **editable mode**:
    ```bash
    pip install -e .
    ```
4.  Run the server:
    ```bash
    mocks-db --schema-content "CREATE TABLE test (id INT);"
    ```
    
    Or run efficiently via python module:
    ```bash
    python -m mocks_db.main --help
    ```

5.  Install development dependencies and run tests:
    
    This project uses `pyproject.toml` for dependency management. You can install the package along with development dependencies (like pytest) using the `[dev]` extra:
    
    ```bash
    pip install -e ".[dev]"
    ```
    
    Or use the legacy requirements style:
    ```bash
    pip install -r requirements-dev.txt
    ```

    Then run tests:
    ```bash
    pytest
    ```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License

[MIT](LICENSE)
