Skip to content

Instantly share code, notes, and snippets.

@omsobliga
Created July 20, 2016 14:26
Show Gist options
  • Save omsobliga/0f7dc19e2ca80302b6083b96a854e229 to your computer and use it in GitHub Desktop.
Save omsobliga/0f7dc19e2ca80302b6083b96a854e229 to your computer and use it in GitHub Desktop.
SQLAlchemy Transaction
# http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Transaction
from sqlalchemy import create_engine
engine = create_engine("postgresql://scott:tiger@localhost/test")
connection = engine.connect()
trans = connection.begin()
connection.execute("insert into x (a, b) values (1, 2)")
trans.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment