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

⚠️ Warning

This is an experimental package. Your fuckups are not mine to fix. You have been warned.

Even though this is an experimental package, I added lots of failsafes to protect the connected DB as to avoid issues.

Create warden.toml in your project:

sqlalchemy_url = "sqlite:///./development.db"

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 config Show current configuration
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

# 6. Check configuration
dbwarden config

Supported Databases

  • PostgreSQL
  • SQLite
  • MySQL

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.5.1.tar.gz (101.4 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.5.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dbwarden-0.1.5.1.tar.gz
Algorithm Hash digest
SHA256 199c7c7e6af16515cc7b9087ac776628c310e163f01665e862681d7d9e7fc116
MD5 28154d1ef94dbe55c97d62768aa69345
BLAKE2b-256 dec0f3d7de540860c06b64be810c688732671ce29068fbf525c344e061cd3d4f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for dbwarden-0.1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 32e11893d6340e520905913879403a300b0038205ed776ac66a5e6a346b68f32
MD5 1cc0d65d6a34acf8af8fbe70ce75306c
BLAKE2b-256 ce6949ad901f09a0deba67af4ef305fb2b5b363de7bfb8ac993cc932e2f0f14b

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