<p dir="auto"><strong>Migrated issue, originally created by Anonymous</strong></p>
<p dir="auto">Our application has a hierarchy containing items for sale: BaseItem, Item, PackItem. BaseItem is the common base class. Item is a 'normal' item, and PackItem is a collection of items sold as one.</p>
<p dir="auto">There is also a class called Collection. A Collection may contain many items, and an item may belong to many collections.</p>
<p dir="auto">Modeling this in SQLAlchemy causes the following runtime error:<br>
Traceback (most recent call last):<br>
File "C:\tmp\testcase.py", line 100, in ?<br>
i = Item()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
mapper.py", line 646, in init<br>
mapper = mapper.compile()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
mapper.py", line 321, in compile<br>
self._compile_all()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
mapper.py", line 341, in _compile_all<br>
mapper._initialize_properties()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
mapper.py", line 596, in _initialize_properties<br>
prop.init(key, self)<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
interfaces.py", line 60, in init<br>
self.do_init()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
properties.py", line 186, in do_init<br>
self._create_polymorphic_joins()<br>
File "c:\python24\lib\site-packages\sqlalchemy-0.3.6-py2.4.egg\sqlalchemy\orm<br>
properties.py", line 382, in _create_polymorphic_joins<br>
raise exceptions.AssertionError(str(self) + ": Could not find corresponding<br>
column for " + str(c) + " in selectable "  + str(self.mapper.select_table))<br>
sqlalchemy.exceptions.AssertionError: Collection.items (BaseItem): Could not fin<br>
d corresponding column for base_item_collection.collection_id in selectable SELE<br>
CT item.dummy, base_item.child_name, item.id<br>
FROM base_item JOIN item ON base_item.id = item.id UNION ALL SELECT CAST(NULL AS<br>
INTEGER) AS dummy, anon_d86.child_name, anon_d86.id<br>
FROM (SELECT base_item.id AS id, base_item.child_name AS child_name<br>
FROM base_item<br>
WHERE base_item.child_name = ?) AS anon_d86</p>
<p dir="auto">It appears that SQLAlchemy assumes the target class of the many-to-many relationship contains the same fields as the join table.</p>
<p dir="auto">The following is a <em>potential</em> fix for your evaluation. It is a slightly modified version of the _determine_remote_side function in sqlalchemy.orm.properties.PropertyLoader. For many-to-many relationships, it does not add the join table's foreign keys to the remote_side collection. This change appears to work in our brief initial testing.</p>
<p dir="auto">def _determine_remote_side(self):<br>
if len(self.remote_side):<br>
return<br>
self.remote_side = util.Set()</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="if self.direction is sync.MANYTOONE:
    for c in self._opposite_side:
        self.remote_side.add(c)
elif self.direction is sync.ONETOMANY:
    for c in self.foreign_keys:
        self.remote_side.add(c)
elif self.direction is sync.MANYTOMANY:
    # The target table for a MANYTOMANY join does
    # not contain the foreign key fields of the join table itself.
    pass"><pre class="notranslate"><code class="notranslate">if self.direction is sync.MANYTOONE:
    for c in self._opposite_side:
        self.remote_side.add(c)
elif self.direction is sync.ONETOMANY:
    for c in self.foreign_keys:
        self.remote_side.add(c)
elif self.direction is sync.MANYTOMANY:
    # The target table for a MANYTOMANY join does
    # not contain the foreign key fields of the join table itself.
    pass
</code></pre></div>
<p dir="auto"><strong>Migrated issue, originally created by Thomas Tanner (<a href="https://github.com/ttanner">@ttanner</a>)</strong></p>
<p dir="auto">sqlalchemy HEAD, mysql 5.5.38, pymysql 0.6.6,<br>
mysql=mysql+pysql://user:password@localhost/test_schema<br>
running<br>
<code class="notranslate">py.test --db mysql --dropfirst --backend-only --log-info=sqlalchemy.orm.mapper  --log-debug=sqlalchemy.pool --log-info=sqlalchemy.engine</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="platform darwin -- Python 3.4.3 -- py-1.4.26 -- pytest-2.7.0 --

DEBUG:sqlalchemy.pool.QueuePool:Created new connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt;
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'sql_mode'
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT DATABASE()
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test plain returns' AS CHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test unicode returns' AS CHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test collated returns' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Created new connection &lt;pymysql.connections.Connection object at 0x108031c18&gt;
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
============================= test session starts ==============================
platform darwin -- Python 3.4.3 -- py-1.4.26 -- pytest-2.7.0 -- 

collecting ... DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SELECT CURRENT_TIMESTAMP AS current_timestamp_1
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
collected 1846 items

test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_insert PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_select PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_select_labels PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_update PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_update_whereclause PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_DecimalResultProcessor_init PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_DecimalResultProcessor_process PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_UnicodeResultProcessor_init PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_ad_hoc_types PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_alias_pathing PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_fixture PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_join_cache PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_key_fallback_result PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_many_discarded_relationships PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_many_updates PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_mapper_reset PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_orm_many_engines PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_path_registry PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_session PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_sessionmaker PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_type_compile PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_unicode_warnings PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_warnings_util PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_with_inheritance PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_with_manytomany PASSED
test/aaa_profiling/test_resultset.py::ExecutionTest_mysql_pymysql::test_minimal_connection_execute FAILEDINFO:sqlalchemy.pool.QueuePool:Pool disposed. Pool size: 5  Connections in pool: 0 Current Overflow: -5 Current Checked out connections: 0
INFO:sqlalchemy.pool.QueuePool:Pool recreating
Encountered a stray connection in test cleanup: {&lt;sqlalchemy.pool._ConnectionRecord object at 0x10ad34f28&gt;}
Traceback (most recent call last):
  File &quot;bin/py.test&quot;, line 9, in &lt;module&gt;
    load_entry_point('pytest==2.7.0', 'console_scripts', 'py.test')()
  File &quot;$site/_pytest/config.py&quot;, line 41, in main
    return config.hook.pytest_cmdline_main(config=config)
  File &quot;$site/_pytest/core.py&quot;, line 521, in __call__
    return self._docall(self.methods, kwargs)
  File &quot;$site/_pytest/core.py&quot;, line 528, in _docall
    firstresult=self.firstresult).execute()
  File &quot;$site/_pytest/core.py&quot;, line 394, in execute
    res = method(*args)
  File &quot;$site/_pytest/main.py&quot;, line 116, in pytest_cmdline_main
    return wrap_session(config, _main)
  File &quot;$site/_pytest/main.py&quot;, line 109, in wrap_session
    exitstatus=session.exitstatus)
  File &quot;$site/_pytest/core.py&quot;, line 521, in __call__
    return self._docall(self.methods, kwargs)
  File &quot;$site/_pytest/core.py&quot;, line 528, in _docall
    firstresult=self.firstresult).execute()
  File &quot;$site/_pytest/core.py&quot;, line 393, in execute
    return wrapped_call(method(*args), self.execute)
  File &quot;$site/_pytest/core.py&quot;, line 109, in wrapped_call
    wrap_controller.send(call_outcome)
  File &quot;$site/_pytest/terminal.py&quot;, line 356, in pytest_sessionfinish
    outcome.get_result()
  File &quot;$site/_pytest/core.py&quot;, line 137, in get_result
    raise ex[1].with_traceback(ex[2])
  File &quot;$site/_pytest/core.py&quot;, line 123, in __init__
    self.result = func()
  File &quot;$site/_pytest/core.py&quot;, line 394, in execute
    res = method(*args)
  File &quot;$site/_pytest/runner.py&quot;, line 55, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File &quot;$site/_pytest/runner.py&quot;, line 375, in teardown_all
    self._pop_and_teardown()
  File &quot;$site/_pytest/runner.py&quot;, line 348, in _pop_and_teardown
    self._teardown_with_finalization(colitem)
  File &quot;$site/_pytest/runner.py&quot;, line 366, in _teardown_with_finalization
    self._callfinalizers(colitem)
  File &quot;$site/_pytest/runner.py&quot;, line 363, in _callfinalizers
    py.builtin._reraise(*exc)
  File &quot;$site/py/_builtin.py&quot;, line 227, in _reraise
    raise cls.with_traceback(val, tb)
  File &quot;$site/_pytest/runner.py&quot;, line 356, in _callfinalizers
    fin()
  File &quot;$path/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py&quot;, line 149, in finalize
    class_teardown(item.parent.parent)
  File &quot;$path/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py&quot;, line 178, in class_teardown
    plugin_base.stop_test_class(item.cls)
  File &quot;$path/test/../lib/sqlalchemy/testing/plugin/plugin_base.py&quot;, line 426, in stop_test_class
    assertions.global_cleanup_assertions()
  File &quot;$path/test/../lib/sqlalchemy/testing/assertions.py&quot;, line 165, in global_cleanup_assertions
    _assert_no_stray_pool_connections()
  File &quot;$path/test/../lib/sqlalchemy/testing/assertions.py&quot;, line 203, in _assert_no_stray_pool_connections
    &quot;after gc.collect(): %s&quot; % err
AssertionError: Stray connection refused to leave after gc.collect(): {&lt;sqlalchemy.pool._ConnectionRecord object at 0x10ad34f28&gt;}"><pre class="notranslate"><code class="notranslate">platform darwin -- Python 3.4.3 -- py-1.4.26 -- pytest-2.7.0 --

DEBUG:sqlalchemy.pool.QueuePool:Created new connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt;
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'sql_mode'
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT DATABASE()
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:show collation where `Charset` = 'utf8' and `Collation` = 'utf8_bin'
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test plain returns' AS CHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test unicode returns' AS CHAR(60)) AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
INFO:sqlalchemy.engine.base.Engine:SELECT CAST('test collated returns' AS CHAR CHARACTER SET utf8) COLLATE utf8_bin AS anon_1
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Created new connection &lt;pymysql.connections.Connection object at 0x108031c18&gt;
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW FULL TABLES FROM `test_schema`
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
============================= test session starts ==============================
platform darwin -- Python 3.4.3 -- py-1.4.26 -- pytest-2.7.0 -- 

collecting ... DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SELECT CURRENT_TIMESTAMP AS current_timestamp_1
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; checked out from pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x108031c18&gt; rollback-on-return
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; checked out from pool
INFO:sqlalchemy.engine.base.Engine:SHOW VARIABLES LIKE 'lower_case_table_names'
INFO:sqlalchemy.engine.base.Engine:()
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; being returned to pool
DEBUG:sqlalchemy.pool.QueuePool:Connection &lt;pymysql.connections.Connection object at 0x10800cf60&gt; rollback-on-return
collected 1846 items

test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_insert PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_select PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_select_labels PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_update PASSED
test/aaa_profiling/test_compiler.py::CompileTest_mysql_pymysql::test_update_whereclause PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_DecimalResultProcessor_init PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_DecimalResultProcessor_process PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_UnicodeResultProcessor_init PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_ad_hoc_types PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_alias_pathing PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_fixture PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_join_cache PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_key_fallback_result PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_many_discarded_relationships PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_many_updates PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_mapper_reset PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_orm_many_engines PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_path_registry PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_session PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_sessionmaker PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_type_compile PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_unicode_warnings PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_warnings_util PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_with_inheritance PASSED
test/aaa_profiling/test_memusage.py::MemUsageTest_mysql_pymysql::test_with_manytomany PASSED
test/aaa_profiling/test_resultset.py::ExecutionTest_mysql_pymysql::test_minimal_connection_execute FAILEDINFO:sqlalchemy.pool.QueuePool:Pool disposed. Pool size: 5  Connections in pool: 0 Current Overflow: -5 Current Checked out connections: 0
INFO:sqlalchemy.pool.QueuePool:Pool recreating
Encountered a stray connection in test cleanup: {&lt;sqlalchemy.pool._ConnectionRecord object at 0x10ad34f28&gt;}
Traceback (most recent call last):
  File "bin/py.test", line 9, in &lt;module&gt;
    load_entry_point('pytest==2.7.0', 'console_scripts', 'py.test')()
  File "$site/_pytest/config.py", line 41, in main
    return config.hook.pytest_cmdline_main(config=config)
  File "$site/_pytest/core.py", line 521, in __call__
    return self._docall(self.methods, kwargs)
  File "$site/_pytest/core.py", line 528, in _docall
    firstresult=self.firstresult).execute()
  File "$site/_pytest/core.py", line 394, in execute
    res = method(*args)
  File "$site/_pytest/main.py", line 116, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "$site/_pytest/main.py", line 109, in wrap_session
    exitstatus=session.exitstatus)
  File "$site/_pytest/core.py", line 521, in __call__
    return self._docall(self.methods, kwargs)
  File "$site/_pytest/core.py", line 528, in _docall
    firstresult=self.firstresult).execute()
  File "$site/_pytest/core.py", line 393, in execute
    return wrapped_call(method(*args), self.execute)
  File "$site/_pytest/core.py", line 109, in wrapped_call
    wrap_controller.send(call_outcome)
  File "$site/_pytest/terminal.py", line 356, in pytest_sessionfinish
    outcome.get_result()
  File "$site/_pytest/core.py", line 137, in get_result
    raise ex[1].with_traceback(ex[2])
  File "$site/_pytest/core.py", line 123, in __init__
    self.result = func()
  File "$site/_pytest/core.py", line 394, in execute
    res = method(*args)
  File "$site/_pytest/runner.py", line 55, in pytest_sessionfinish
    session._setupstate.teardown_all()
  File "$site/_pytest/runner.py", line 375, in teardown_all
    self._pop_and_teardown()
  File "$site/_pytest/runner.py", line 348, in _pop_and_teardown
    self._teardown_with_finalization(colitem)
  File "$site/_pytest/runner.py", line 366, in _teardown_with_finalization
    self._callfinalizers(colitem)
  File "$site/_pytest/runner.py", line 363, in _callfinalizers
    py.builtin._reraise(*exc)
  File "$site/py/_builtin.py", line 227, in _reraise
    raise cls.with_traceback(val, tb)
  File "$site/_pytest/runner.py", line 356, in _callfinalizers
    fin()
  File "$path/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py", line 149, in finalize
    class_teardown(item.parent.parent)
  File "$path/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py", line 178, in class_teardown
    plugin_base.stop_test_class(item.cls)
  File "$path/test/../lib/sqlalchemy/testing/plugin/plugin_base.py", line 426, in stop_test_class
    assertions.global_cleanup_assertions()
  File "$path/test/../lib/sqlalchemy/testing/assertions.py", line 165, in global_cleanup_assertions
    _assert_no_stray_pool_connections()
  File "$path/test/../lib/sqlalchemy/testing/assertions.py", line 203, in _assert_no_stray_pool_connections
    "after gc.collect(): %s" % err
AssertionError: Stray connection refused to leave after gc.collect(): {&lt;sqlalchemy.pool._ConnectionRecord object at 0x10ad34f28&gt;}
</code></pre></div>
<p dir="auto">without logging and with duplicate errors removed (table users exists):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="==================================== ERRORS ====================================
 ERROR at setup of ComponentReflectionTest_mysql_pymysql.test_autoincrement_col 
Traceback (most recent call last):
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1139, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/default.py&quot;, line 442, in do_execute
    cursor.execute(statement, parameters)
  File &quot;$site/pymysql/cursors.py&quot;, line 134, in execute
    result = self._query(query)
  File &quot;$site/pymysql/cursors.py&quot;, line 282, in _query
    conn.query(q)
  File &quot;$site/pymysql/connections.py&quot;, line 768, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File &quot;$site/pymysql/connections.py&quot;, line 929, in _read_query_result
    result.read()
  File &quot;$site/pymysql/connections.py&quot;, line 1125, in read
    first_packet = self.connection._read_packet()
  File &quot;$site/pymysql/connections.py&quot;, line 893, in _read_packet
    packet.check_error()
  File &quot;$site/pymysql/connections.py&quot;, line 369, in check_error
    err.raise_mysql_exception(self._data)
  File &quot;$site/pymysql/err.py&quot;, line 120, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File &quot;$site/pymysql/err.py&quot;, line 115, in _check_mysql_exception
    raise InternalError(errno, errorvalue)
pymysql.err.InternalError: (1050, &quot;Table 'users' already exists&quot;)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File &quot;$path/test/../lib/sqlalchemy/testing/fixtures.py&quot;, line 83, in setup_class
    cls._setup_once_tables()
  File &quot;$path/test/../lib/sqlalchemy/testing/fixtures.py&quot;, line 112, in _setup_once_tables
    cls.metadata.create_all(cls.bind)
  File &quot;$path/test/../lib/sqlalchemy/sql/schema.py&quot;, line 3611, in create_all
    tables=tables)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;$path/test/../lib/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 727, in visit_metadata
    _is_metadata_operation=True)
  File &quot;$path/test/../lib/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 914, in execute
    return meth(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 968, in _execute_ddl
    compiled
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1146, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1332, in _handle_dbapi_exception
    exc_info
  File &quot;$path/test/../lib/sqlalchemy/util/compat.py&quot;, line 188, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
  File &quot;$path/test/../lib/sqlalchemy/util/compat.py&quot;, line 181, in reraise
    raise value.with_traceback(tb)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1139, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/default.py&quot;, line 442, in do_execute
    cursor.execute(statement, parameters)
  File &quot;$site/pymysql/cursors.py&quot;, line 134, in execute
    result = self._query(query)
  File &quot;$site/pymysql/cursors.py&quot;, line 282, in _query
    conn.query(q)
  File &quot;$site/pymysql/connections.py&quot;, line 768, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File &quot;$site/pymysql/connections.py&quot;, line 929, in _read_query_result
    result.read()
  File &quot;$site/pymysql/connections.py&quot;, line 1125, in read
    first_packet = self.connection._read_packet()
  File &quot;$site/pymysql/connections.py&quot;, line 893, in _read_packet
    packet.check_error()
  File &quot;$site/pymysql/connections.py&quot;, line 369, in check_error
    err.raise_mysql_exception(self._data)
  File &quot;$site/pymysql/err.py&quot;, line 120, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File &quot;$site/pymysql/err.py&quot;, line 115, in _check_mysql_exception
    raise InternalError(errno, errorvalue)
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1050, &quot;Table 'users' already exists&quot;) [SQL: '\nCREATE TABLE test_schema.users (\n\tuser_id INTEGER NOT NULL AUTO_INCREMENT, \n\ttest1 CHAR(5) NOT NULL, \n\ttest2 FLOAT(5) NOT NULL, \n\tparent_user_id INTEGER, \n\tPRIMARY KEY (user_id), \n\tFOREIGN KEY(parent_user_id) REFERENCES test_schema.users (user_id)\n)ENGINE=InnoDB\n\n']

...
=================================== FAILURES ===================================
_________________ EnumSetTest_mysql_pymysql.test_unicode_enum __________________
Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 2, in test_unicode_enum
  File &quot;$path/test/../lib/sqlalchemy/testing/util.py&quot;, line 195, in provide_metadata
    return fn(*args, **kw)
  File &quot;$path/test/dialect/mysql/test_types.py&quot;, line 914, in test_unicode_enum
    metadata.create_all()
  File &quot;$path/test/../lib/sqlalchemy/sql/schema.py&quot;, line 3611, in create_all
    tables=tables)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;$path/test/../lib/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 727, in visit_metadata
    _is_metadata_operation=True)
  File &quot;$path/test/../lib/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 914, in execute
    return meth(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 968, in _execute_ddl
    compiled
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1146, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1335, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File &quot;$path/test/../lib/sqlalchemy/util/compat.py&quot;, line 182, in reraise
    raise value
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1139, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/default.py&quot;, line 442, in do_execute
    cursor.execute(statement, parameters)
  File &quot;$site/pymysql/cursors.py&quot;, line 134, in execute
    result = self._query(query)
  File &quot;$site/pymysql/cursors.py&quot;, line 282, in _query
    conn.query(q)
  File &quot;$site/pymysql/connections.py&quot;, line 766, in query
    sql = sql.encode(self.encoding, 'surrogateescape')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 95: ordinal not in range(256)
_______________ EnumSetTest_mysql_pymysql.test_unicode_roundtrip _______________
Traceback (most recent call last):
  File &quot;&lt;string&gt;&quot;, line 2, in test_unicode_roundtrip
  File &quot;$path/test/../lib/sqlalchemy/testing/util.py&quot;, line 195, in provide_metadata
    return fn(*args, **kw)
  File &quot;$path/test/dialect/mysql/test_types.py&quot;, line 830, in test_unicode_roundtrip
    set_table.create()
  File &quot;$path/test/../lib/sqlalchemy/sql/schema.py&quot;, line 725, in create
    checkfirst=checkfirst)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File &quot;$path/test/../lib/sqlalchemy/sql/visitors.py&quot;, line 121, in traverse_single
    return meth(obj, **kw)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 914, in execute
    return meth(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/sql/ddl.py&quot;, line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 968, in _execute_ddl
    compiled
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1146, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1335, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File &quot;$path/test/../lib/sqlalchemy/util/compat.py&quot;, line 182, in reraise
    raise value
  File &quot;$path/test/../lib/sqlalchemy/engine/base.py&quot;, line 1139, in _execute_context
    context)
  File &quot;$path/test/../lib/sqlalchemy/engine/default.py&quot;, line 442, in do_execute
    cursor.execute(statement, parameters)
  File &quot;$site/pymysql/cursors.py&quot;, line 134, in execute
    result = self._query(query)
  File &quot;$site/pymysql/cursors.py&quot;, line 282, in _query
    conn.query(q)
  File &quot;$site/pymysql/connections.py&quot;, line 766, in query
    sql = sql.encode(self.encoding, 'surrogateescape')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 87: ordinal not in range(256)
=========================== short test summary info ============================
FAIL test/dialect/mysql/test_types.py::EnumSetTest_mysql_pymysql::()::test_unicode_enum
FAIL test/dialect/mysql/test_types.py::EnumSetTest_mysql_pymysql::()::test_unicode_roundtrip
!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 25 failures !!!!!!!!!!!!!!!!!!!!
========= 2 failed, 95 passed, 334 skipped, 23 error in 62.13 seconds =========="><pre class="notranslate"><code class="notranslate">==================================== ERRORS ====================================
 ERROR at setup of ComponentReflectionTest_mysql_pymysql.test_autoincrement_col 
Traceback (most recent call last):
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
  File "$site/pymysql/cursors.py", line 134, in execute
    result = self._query(query)
  File "$site/pymysql/cursors.py", line 282, in _query
    conn.query(q)
  File "$site/pymysql/connections.py", line 768, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "$site/pymysql/connections.py", line 929, in _read_query_result
    result.read()
  File "$site/pymysql/connections.py", line 1125, in read
    first_packet = self.connection._read_packet()
  File "$site/pymysql/connections.py", line 893, in _read_packet
    packet.check_error()
  File "$site/pymysql/connections.py", line 369, in check_error
    err.raise_mysql_exception(self._data)
  File "$site/pymysql/err.py", line 120, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File "$site/pymysql/err.py", line 115, in _check_mysql_exception
    raise InternalError(errno, errorvalue)
pymysql.err.InternalError: (1050, "Table 'users' already exists")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "$path/test/../lib/sqlalchemy/testing/fixtures.py", line 83, in setup_class
    cls._setup_once_tables()
  File "$path/test/../lib/sqlalchemy/testing/fixtures.py", line 112, in _setup_once_tables
    cls.metadata.create_all(cls.bind)
  File "$path/test/../lib/sqlalchemy/sql/schema.py", line 3611, in create_all
    tables=tables)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File "$path/test/../lib/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 727, in visit_metadata
    _is_metadata_operation=True)
  File "$path/test/../lib/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 968, in _execute_ddl
    compiled
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1332, in _handle_dbapi_exception
    exc_info
  File "$path/test/../lib/sqlalchemy/util/compat.py", line 188, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=exc_value)
  File "$path/test/../lib/sqlalchemy/util/compat.py", line 181, in reraise
    raise value.with_traceback(tb)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
  File "$site/pymysql/cursors.py", line 134, in execute
    result = self._query(query)
  File "$site/pymysql/cursors.py", line 282, in _query
    conn.query(q)
  File "$site/pymysql/connections.py", line 768, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "$site/pymysql/connections.py", line 929, in _read_query_result
    result.read()
  File "$site/pymysql/connections.py", line 1125, in read
    first_packet = self.connection._read_packet()
  File "$site/pymysql/connections.py", line 893, in _read_packet
    packet.check_error()
  File "$site/pymysql/connections.py", line 369, in check_error
    err.raise_mysql_exception(self._data)
  File "$site/pymysql/err.py", line 120, in raise_mysql_exception
    _check_mysql_exception(errinfo)
  File "$site/pymysql/err.py", line 115, in _check_mysql_exception
    raise InternalError(errno, errorvalue)
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1050, "Table 'users' already exists") [SQL: '\nCREATE TABLE test_schema.users (\n\tuser_id INTEGER NOT NULL AUTO_INCREMENT, \n\ttest1 CHAR(5) NOT NULL, \n\ttest2 FLOAT(5) NOT NULL, \n\tparent_user_id INTEGER, \n\tPRIMARY KEY (user_id), \n\tFOREIGN KEY(parent_user_id) REFERENCES test_schema.users (user_id)\n)ENGINE=InnoDB\n\n']

...
=================================== FAILURES ===================================
_________________ EnumSetTest_mysql_pymysql.test_unicode_enum __________________
Traceback (most recent call last):
  File "&lt;string&gt;", line 2, in test_unicode_enum
  File "$path/test/../lib/sqlalchemy/testing/util.py", line 195, in provide_metadata
    return fn(*args, **kw)
  File "$path/test/dialect/mysql/test_types.py", line 914, in test_unicode_enum
    metadata.create_all()
  File "$path/test/../lib/sqlalchemy/sql/schema.py", line 3611, in create_all
    tables=tables)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File "$path/test/../lib/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 727, in visit_metadata
    _is_metadata_operation=True)
  File "$path/test/../lib/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 968, in _execute_ddl
    compiled
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1335, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File "$path/test/../lib/sqlalchemy/util/compat.py", line 182, in reraise
    raise value
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
  File "$site/pymysql/cursors.py", line 134, in execute
    result = self._query(query)
  File "$site/pymysql/cursors.py", line 282, in _query
    conn.query(q)
  File "$site/pymysql/connections.py", line 766, in query
    sql = sql.encode(self.encoding, 'surrogateescape')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 95: ordinal not in range(256)
_______________ EnumSetTest_mysql_pymysql.test_unicode_roundtrip _______________
Traceback (most recent call last):
  File "&lt;string&gt;", line 2, in test_unicode_roundtrip
  File "$path/test/../lib/sqlalchemy/testing/util.py", line 195, in provide_metadata
    return fn(*args, **kw)
  File "$path/test/dialect/mysql/test_types.py", line 830, in test_unicode_roundtrip
    set_table.create()
  File "$path/test/../lib/sqlalchemy/sql/schema.py", line 725, in create
    checkfirst=checkfirst)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1843, in _run_visitor
    conn._run_visitor(visitorcallable, element, **kwargs)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1471, in _run_visitor
    **kwargs).traverse_single(element)
  File "$path/test/../lib/sqlalchemy/sql/visitors.py", line 121, in traverse_single
    return meth(obj, **kw)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 761, in visit_table
    include_foreign_key_constraints=include_foreign_key_constraints
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/sql/ddl.py", line 68, in _execute_on_connection
    return connection._execute_ddl(self, multiparams, params)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 968, in _execute_ddl
    compiled
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1335, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File "$path/test/../lib/sqlalchemy/util/compat.py", line 182, in reraise
    raise value
  File "$path/test/../lib/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "$path/test/../lib/sqlalchemy/engine/default.py", line 442, in do_execute
    cursor.execute(statement, parameters)
  File "$site/pymysql/cursors.py", line 134, in execute
    result = self._query(query)
  File "$site/pymysql/cursors.py", line 282, in _query
    conn.query(q)
  File "$site/pymysql/connections.py", line 766, in query
    sql = sql.encode(self.encoding, 'surrogateescape')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2019' in position 87: ordinal not in range(256)
=========================== short test summary info ============================
FAIL test/dialect/mysql/test_types.py::EnumSetTest_mysql_pymysql::()::test_unicode_enum
FAIL test/dialect/mysql/test_types.py::EnumSetTest_mysql_pymysql::()::test_unicode_roundtrip
!!!!!!!!!!!!!!!!!!! Interrupted: stopping after 25 failures !!!!!!!!!!!!!!!!!!!!
========= 2 failed, 95 passed, 334 skipped, 23 error in 62.13 seconds ==========
</code></pre></div>