Skip to content

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

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO SQLto_sql, read_sql, read_sql_query

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions