Hi,
I played with it a bit and here's what I got:
http://hg.in-square.net/sqlalchemy-migrate/rev/481c8fa97ce9 Basically, for each script executed, it will create and destroy connection. Instead of passing engine to the script, it will pass connection object instead.
If script requires Engine for some reason, it is always accessible using conn.engine property. Also, connection and engine are generally exchangeable,
so in some cases (MockConnection which does not have connect/close) Engine can be passed instead.
I also changed tests to use connection instead of engine. Problem is that I'm using Windows x64 and Python x64, which does not have bindings to anything except of SQLite. All tests pass for SQLite, except of shell tests, as it can't find migrate script. I will migrate to x86 Python and will try it with PostgreSQL.
SQLite notice: transactions don't help at all - pysqlite (or sqlite3) always commits transaction for scheme modification queries, commits before every select query (or PRAGMA statement), etc. See more information here:
http://docs.python.org/library/sqlite3.html#controlling-transactions. I was bashing head against the wall for last day, trying to figure out why table stays in the database after rollback, even though exactly same SQL works fine when executed from sqlite3 console tool.
P.S. My text editor automatically removes trailing spaces, so diff contains some lines that appear to have no visible changes.
Serge.