Skip to main content

SQLAlachemy migration maker.Generate SQL command to auto migrate

Project description

SQLAlchemy Migration Maker

SQLalchemy 是個 Python 的 Database Library,可以與 Postgres、MySQL 與其他 Database 連結,但是卻缺少了更新 Database 的功能。
受到 Django Database 的啟發,我寫了這套件使更新更輕鬆,把 Database 結構化成特別的 Id,並存到資料庫,透過比較結構來決定需要下哪些 SQL 指令。

SQLalchemy is a python library that deal with database. Can be used to connect with Postgres, MySQL, etc. But it lack of builtin migrate functionality.
Inspire by django db manager, I write this package to migrate db more easily.
It turn Database structure into special id then store in database.
When there's new version structure, it compares two version then decide what SQL command need to be executed.
This package need to setup yourself


pip install sqlalchemy-migration-maker


  • sqlalchemy


Require psycopg2

In my testing, I use postgres database to execute sql language

Tested Envirment

  • MacOSX
  • Python3

Tested Database

  • Postgres


from sqlalchemy import Column
from sqlalchemy.types import Integer
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class User(Base):
    __tablename__ = "user"

    id = Column(Integer, primary_key=True, autoincrement=True)

    def __repr__(self):
        return f"<User {} {self.create_at}>"

from .model import Base
from migrationmaker import VersionControl

version_ctl = VersionCtrol("{DB_URI}")

# 檢查版本控制是否存在於 DB
# Check version ctrl exist in DB

# 取回舊版本
# Retrieve old version

# 指定新版本
# Assign new version

if not self.version_ctl.check_same():

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

sqlalchemy-migration-maker-0.4.tar.gz (7.4 kB view hashes)

Uploaded source

Built Distribution

Supported by

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