Metadata-Version: 2.4
Name: dbwarden
Version: 0.1.3
Summary: Database migration system for Python/SQLAlchemy projects
Author-email: Emiliano Gandini Outeda <emiliano.gandini@protonmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: database,fastapi,migrations,postgres,sqlalchemy
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Requires-Dist: aiosqlite>=0.22.1
Requires-Dist: asyncpg<0.32.0,>=0.29.0
Requires-Dist: packaging>=25.0
Requires-Dist: rich>=12.2.0
Requires-Dist: sqlalchemy>=2.0.10
Requires-Dist: typer>=0.12.3
Provides-Extra: dev
Requires-Dist: psycopg2-binary>=2.9.11; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.4.2; extra == 'dev'
Provides-Extra: postgres-async
Requires-Dist: asyncpg<0.32.0,>=0.29.0; extra == 'postgres-async'
Requires-Dist: sqlalchemy[postgresql]>=2.0.10; extra == 'postgres-async'
Provides-Extra: postgres-sync
Requires-Dist: psycopg2-binary>=2.9.11; extra == 'postgres-sync'
Provides-Extra: sqlite-async
Requires-Dist: aiosqlite>=0.22.1; extra == 'sqlite-async'
Description-Content-Type: text/markdown

<div align="center">

# DBWarden

A database migration system for Python/SQLAlchemy projects.

<a href="https://emiliano-gandini-outeda.github.io/DBWarden/">
  <img src="https://img.shields.io/badge/docs-mkdocs-blue.svg" alt="Documentation">
</a>
<a href="https://deepwiki.com/emiliano-gandini-outeda/DBWarden">
  <img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
</a>

</div>

## Installation

```bash
pip install dbwarden
```

## Configuration

Create `warden.toml` in your project:

```toml
sqlalchemy_url = "sqlite:///./development.db"
async = false
```

Or use environment variables:

```env
DBWARDEN_SQLALCHEMY_URL=postgresql://user:pass@localhost/db
DBWARDEN_ASYNC=false  # or true for async mode
```

## Basic Commands

| Command | Description |
|---------|-------------|
| `dbwarden init` | Initialize migrations directory |
| `dbwarden make-migrations "name"` | Generate SQL from SQLAlchemy models |
| `dbwarden migrate` | Apply pending migrations |
| `dbwarden migrate --verbose` | Apply with detailed logging |
| `dbwarden rollback` | Revert the last migration |
| `dbwarden history` | Show migration history |
| `dbwarden status` | Show current status |
| `dbwarden mode` | Show sync/async mode |
| `dbwarden check-db` | Inspect DB schema |
| `dbwarden diff` | Show models vs DB differences |

## SQLAlchemy Models

DBWarden automatically detects models in `models/`:

```python
# models/user.py
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True)
    name = Column(String(100))
    email = Column(String(255), unique=True)
```

## Complete Example

```bash
# 1. Initialize
dbwarden init

# 2. Create models in models/

# 3. Generate migration from models
dbwarden make-migrations "create users table"

# 4. Apply
dbwarden migrate --verbose

# 5. View history
dbwarden history
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `DBWARDEN_SQLALCHEMY_URL` | DB connection URL |
| `DBWARDEN_ASYNC` | Async mode (`true`/`false`) |
| `DBWARDEN_MODEL_PATHS` | Paths to SQLAlchemy models |

## Supported Databases

- PostgreSQL (sync + async)
- SQLite (sync + async)
- MySQL (sync)

## Docs

For more information, see [DBWarden Docs](http://emiliano-gandini-outeda.me/DBWarden/) or [DBWarden DeepWiki page](https://deepwiki.com/emiliano-gandini-outeda/DBWarden)

## License

This Project is Licensed under the MIT License. See [LICENSE](https://github.com/emiliano-gandini-outeda/DBWarden/blob/main/LICENSE)
