SQLAlchemy integration

Here's another update: https://gist.github.com/tsukanov/80d3fbe175ae301cfce7. Should be correct now.