Traceback generated by script above: (myenv) ➜ myenv python new_script.py 2016-08-23 13:41:26,665 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'sql_mode' 2016-08-23 13:41:26,665 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,668 INFO sqlalchemy.engine.base.Engine SELECT DATABASE() 2016-08-23 13:41:26,668 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,671 INFO sqlalchemy.engine.base.Engine show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin' 2016-08-23 13:41:26,671 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,673 INFO sqlalchemy.engine.base.Engine SELECT CAST('test plain returns' AS CHAR(60)) AS anon_1 2016-08-23 13:41:26,673 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,675 INFO sqlalchemy.engine.base.Engine SELECT CAST('test unicode returns' AS CHAR(60)) AS anon_1 2016-08-23 13:41:26,675 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,676 INFO sqlalchemy.engine.base.Engine SELECT CAST('test collated returns' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin AS anon_1 2016-08-23 13:41:26,676 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,677 INFO sqlalchemy.engine.base.Engine DESCRIBE `a` 2016-08-23 13:41:26,677 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,685 INFO sqlalchemy.engine.base.Engine ROLLBACK 2016-08-23 13:41:26,686 INFO sqlalchemy.engine.base.Engine DESCRIBE `a` 2016-08-23 13:41:26,686 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,687 INFO sqlalchemy.engine.base.Engine ROLLBACK 2016-08-23 13:41:26,688 INFO sqlalchemy.engine.base.Engine CREATE TABLE a ( id INTEGER NOT NULL, PRIMARY KEY (id) ) 2016-08-23 13:41:26,688 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,741 INFO sqlalchemy.engine.base.Engine COMMIT 2016-08-23 13:41:26,742 INFO sqlalchemy.engine.base.Engine BEGIN (implicit) 2016-08-23 13:41:26,742 INFO sqlalchemy.engine.base.Engine SAVEPOINT sa_savepoint_1 2016-08-23 13:41:26,742 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,743 INFO sqlalchemy.engine.base.Engine rollback 2016-08-23 13:41:26,743 INFO sqlalchemy.engine.base.Engine {} 2016-08-23 13:41:26,745 INFO sqlalchemy.engine.base.Engine INSERT INTO a () VALUES () 2016-08-23 13:41:26,745 INFO sqlalchemy.engine.base.Engine {} /Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/cursors.py:167: Warning: (1364, "Field 'id' doesn't have a default value") result = self._query(query) 2016-08-23 13:41:26,752 INFO sqlalchemy.engine.base.Engine ROLLBACK TO SAVEPOINT sa_savepoint_1 2016-08-23 13:41:26,752 INFO sqlalchemy.engine.base.Engine {} /Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py:430: SAWarning: An exception raised during a Session persistence operation cannot be raised due to an additional ROLLBACK exception; the exception is: Instance has a NULL identity key. If this is an auto-generated value, check that the database table allows generation of new primary key values, and that the mapped Column object is configured to expect these generated values. Ensure also that this flush() is not occurring at an inappropriate time, such aswithin a load() event. "the exception is: %s" % captured_exception) Traceback (most recent call last): File "new_script.py", line 17, in s.commit() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 813, in commit self.transaction.commit() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 392, in commit self._prepare_impl() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl self.session.flush() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2027, in flush self._flush(objects) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2145, in _flush transaction.rollback(_capture_exception=True) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 63, in __exit__ compat.reraise(type_, value, traceback) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 2145, in _flush transaction.rollback(_capture_exception=True) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 423, in rollback from sqlalchemy.orm import Session from sqlalchemy import create_engine, Column, Integer from sqlalchemy.ext.declarative import declarative_base transaction._rollback_impl() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 461, in _rollback_impl t[1].rollback() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1563, in rollback self._do_rollback() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1625, in _do_rollback self._savepoint, self._parent) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 717, in _rollback_to_savepoint_impl self.engine.dialect.do_rollback_to_savepoint(self, name) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 441, in do_rollback_to_savepoint connection.execute(expression.RollbackToSavepointClause(name)) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 914, in execute return meth(self, multiparams, params) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement compiled_sql, distilled_params File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context context) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception exc_info File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context context) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 450, in do_execute cursor.execute(statement, parameters) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/cursors.py", line 167, in execute result = self._query(query) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/cursors.py", line 323, in _query conn.query(q) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/connections.py", line 836, in query self._affected_rows = self._read_query_result(unbuffered=unbuffered) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/connections.py", line 1020, in _read_query_result result.read() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/connections.py", line 1303, in read first_packet = self.connection._read_packet() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/connections.py", line 982, in _read_packet packet.check_error() File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/connections.py", line 394, in check_error err.raise_mysql_exception(self._data) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/err.py", line 120, in raise_mysql_exception _check_mysql_exception(errinfo) File "/Users/aignatov/work/myenv/lib/python2.7/site-packages/pymysql/err.py", line 115, in _check_mysql_exception raise InternalError(errno, errorvalue) sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1305, u'SAVEPOINT sa_savepoint_1 does not exist') [SQL: u'ROLLBACK TO SAVEPOINT sa_savepoint_1']