Should I use Pylons or Pyramid?

Pylons isn’t being “cancelled”, and it will continue to receive updates. That said, the “future” per se is in Pyramid. On the mailing list is has been referred to as Pylons 2.0. It is fully tested and better documented than Pylons 1.0, so you might as well jump aboard if you’re fresh. Pyramid is essentially … Read more

How to efficiently manage frequent schema changes using sqlalchemy?

Alembic is a new database migrations tool, written by the author of SQLAlchemy. I’ve found it much easier to use than sqlalchemy-migrate. It also works seamlessly with Flask-SQLAlchemy. Auto generate the schema migration script from your SQLAlchemy models: alembic revision –autogenerate -m “description of changes” Then apply the new schema changes to your database: alembic … Read more

SQLAlchemy printing raw SQL from create()

from sqlalchemy.schema import CreateTable print(CreateTable(table)) If you are using declarative syntax: print(CreateTable(Model.__table__)) Update: Since I have the accepted answer and there is important information in klenwell answer, I’ll also add it here. You can get the SQL for your specific database (MySQL, Postgresql, etc.) by compiling with your engine. print(CreateTable(Model.__table__).compile(engine)) Update 2: @jackotonye Added in … Read more

SQLAlchemy, clear database content but don’t drop the schema

I asked about the same thing on the SQLAlchemy Google group, and I got a recipe that appears to work well (all my tables are emptied). See the thread for reference. My code (excerpt) looks like this: import contextlib from sqlalchemy import MetaData meta = MetaData() with contextlib.closing(engine.connect()) as con: trans = con.begin() for table … Read more