Skip to content

StandaloneDynamics/python3-litemigration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python3-litemigration 1.1.1

Simple module to keep database changes up to date in sql

While I was busy building small database based applications, I needed a way to

  1. modify the database without corrupting the current data
  2. keeping track of all the changes that have been made

All my small applications are done in sql, so it made sense to make/track changes in sql as well.

Two of my Gtk applications use this module

Letmenotifyu

ClientContacts

Supported Databases

Sqlite3

PostgreSQL

Example Usage

from litemigration.database import Database

db = Database('sqlite', database="Test.sqlite")
db.initialise()
db.add_schema([
    [1, "CREATE TABLE cats(id INTEGER PRIMARY KEY,name TEXT)"],
    [2, "CREATE TABLE dogs(id INTEGER PRIMARY KEY)"],
    [3, "CREATE TABLE house(id INTEGER)"],
    [4, "INSERT INTO cats(name) VALUES('jow')"]
])

So if you want to add a new change all you would have to do is to add another entry to the add_schema method.

[5,"INSERT INTO names(name) VALUES('me')"]

When your application starts up it will run through all the changes to make sure they have been applied and apply any new ones.

About

Simple module to keep database changes up to date in raw sql

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages