Randrian
Randrian

Reputation: 1085

Peewee adding columns on demand

I have an sqlite database which I use as a data storage file for an application I develop in python.

Now the development of new features requires me to define new fields in the database. Is there a way, with peewee, of loading a database file, which used the old table definition (without new field) without getting an SQLError: no such column error?

Like an automatic insertion of the new field with a default value in the database. This would make life a lot easier for having backwards compatibility with opening database files from previous versions.

Upvotes: 3

Views: 6019

Answers (1)

coleifer
coleifer

Reputation: 26235

I've written a web-based tool called sqlite-web that will allow you to manage your database schema using a GUI.

If you want to add columns on the fly in your Python code, check out peewee's migration extension: http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#schema-migrations

Upvotes: 5

Related Questions