Database migration system for Python/SQLAlchemy projects
Project description
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:
database_type = "sqlite"
sqlalchemy_url = "sqlite:///./development.db"
ClickHouse example:
database_type = "clickhouse"
sqlalchemy_url = "clickhousedb+connect://user:password@localhost:8123/analytics"
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
- ClickHouse
Docs
For more information, see DBWarden Docs or DBWarden DeepWiki page
License
This Project is Licensed under the MIT License. See LICENSE
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbwarden-0.2.2.tar.gz.
File metadata
- Download URL: dbwarden-0.2.2.tar.gz
- Upload date:
- Size: 438.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00e21d075efc3156bbe85726d2758c35dc9cd60b377e7ff6b128086b4b468484
|
|
| MD5 |
1d682567fd450a5fcb0b962e483dc879
|
|
| BLAKE2b-256 |
f4e0e5ebecd1aeb2e73f2b391c62d7c6268ecff0fdb7882eed2e88b660a72e52
|
File details
Details for the file dbwarden-0.2.2-py3-none-any.whl.
File metadata
- Download URL: dbwarden-0.2.2-py3-none-any.whl
- Upload date:
- Size: 38.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b02348a80c883da7966d495626b58c97293701882aec3b3ce61626ad82bbebce
|
|
| MD5 |
9ab419263085a2b3d8ca57ddc1449fb9
|
|
| BLAKE2b-256 |
3f6d19ef001b3d2b35cad2751954e9bdf8bd01b63fc05f73482f57c169759255
|