Skip to content

SQL: use of connection context manager not supported by mysql.connector #8277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jorisvandenbossche opened this issue Sep 15, 2014 · 1 comment · Fixed by #8278
Closed

SQL: use of connection context manager not supported by mysql.connector #8277

jorisvandenbossche opened this issue Sep 15, 2014 · 1 comment · Fixed by #8278
Labels
IO SQL to_sql, read_sql, read_sql_query
Milestone

Comments

@jorisvandenbossche
Copy link
Member

Coming from discussion in #8232, current master breaks with mysql.connector as the MySQL driver in the fallback modus (deprecated) due to the use of context managers.

This was introduced in #8062, to ensure that the different chunks would be inserted in one transaction (when using the chunksize argument).

The connection context manager is however nog DBAPI specified behaviour, and differs among drivers:

  • sqlite3 returns a connection from the context manager, but has a connection.executemany, so that of course works (otherwise the tests would not pass at all)
  • pymysql returns a cursor, but does not close that cursor automatically (I don't know if this is a problem)
  • MySQLdb does now support such a context manager (from 1.2.5, so only the latest version), and does the same as pymysql
  • mysql.connector does not support it, so the current implementation fails with that.

So problem is that with the current code in master, we break the fallback mode when using mysql.connector.

Solution: I think remove the context managers for now (which will make the code a bit more complex), until mysql support is fully dropped

@artemyk
Copy link
Contributor

artemyk commented Sep 16, 2014

@jorisvandenbossche Added a pull request to deal with this issue in #8278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants