Skip to main content

Database migration system for Python/SQLAlchemy projects

Project description

DBWarden

A database migration system for Python/SQLAlchemy projects.

Documentation Ask DeepWiki

Installation

pip install dbwarden

Configuration

Create .env in your project:

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/:

# 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

# 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 or DBWarden DeepWiki page

License

This Project is Licensed under the MIT License. See LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbwarden-0.1.2.tar.gz (66.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbwarden-0.1.2-py3-none-any.whl (37.1 kB view details)

Uploaded Python 3

File details

Details for the file dbwarden-0.1.2.tar.gz.

File metadata

  • Download URL: dbwarden-0.1.2.tar.gz
  • Upload date:
  • Size: 66.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dbwarden-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2176f2adfb51165b6f477dcdcb9ff0e06bd23280f7f14918d48cb1af3dd6bf06
MD5 1e51867859fed288fcae3e0b66a361f0
BLAKE2b-256 621bd5aa1995f5f0aea440075ba8bc0cac8f1862fb7761d3eebdf0821ca4afe5

See more details on using hashes here.

File details

Details for the file dbwarden-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dbwarden-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 37.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for dbwarden-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e41698e3cd1a152f1d563275f1995871db7bfd12c0d7eedd9364c15e8a931a7
MD5 cb3742a9ca13068fa30a4fdad2cdc7e4
BLAKE2b-256 870b80c8509e78552a58cfc8816d06dbff4e17283287791a094e2a0b8a545263

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page