2

I'm using SqlAlchemy in my Pylons application to access data and SqlAlchemy-migrate to maintain the database schema.

It works fine for managing the schema itself. However, I also want to manage seed data in a migrate-like way. E.g. when ProductCategory table is created it would make sense to seed it with categories data.

Looks like SqlAlchemy-migrate does not support this directly. What would be a good approach to do this with Pylons+SqlAlchemy+SqlAlchemy-migrate?

Dima Malenko
  • 2,805
  • 2
  • 27
  • 24

1 Answers1

2

Well what format is your seed data starting out in? The migrate calls are just python methods so you're free to open some csv, create SA object instances, loop, etc. I usually have my seed data as a series of sql insert statements and just loop over them executing a migate.execute(query) for each one.

So I'll first create the table, loop and run seed data, and then empty/drop table on the downgrade method.

Rick
  • 15,484
  • 5
  • 25
  • 29