[CONPY-269] mariadb throws a "cursor closed" when inserting using Pandas API Created: 2023-09-13 Updated: 2023-10-11 Resolved: 2023-09-29 |
|
| Status: | Closed |
| Project: | MariaDB Connector/Python |
| Component/s: | DBAPI 2.0 |
| Affects Version/s: | 1.1.7 |
| Fix Version/s: | 1.1.8 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marshall | Assignee: | Georg Richter |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Machine: MacBook (Intel) (relevant) python packages: |
||
| Python Version: | 3.10.13 |
| Description |
|
I'm running into a similar issue as outlined here, which was supposedly fixed in this ticket, however I'm still running into the problem relevant code I'm using:
|
| Comments |
| Comment by Marshall [ 2023-09-13 ] | |||||||||||||||||||||
|
I have no idea how tickets get tracked/worked on at this organization, so let me know if you want the stacktrace and I can add it | |||||||||||||||||||||
| Comment by Georg Richter [ 2023-09-27 ] | |||||||||||||||||||||
|
No need for a stacktrace, I can reproduce the problem now. | |||||||||||||||||||||
| Comment by Georg Richter [ 2023-09-27 ] | |||||||||||||||||||||
|
According to PEP-249: .close() When debugging your script, it turns out, that SQLAlchemy calls cursor.close() and afterwards wants to access cursor.rowcount while cursor was already closed. I would say this is not a bug in Connector/Python, since it's clearly defined that the cursor become unusable after closing it. PyMySQL seems to ignore it:
| |||||||||||||||||||||
| Comment by Georg Richter [ 2023-09-29 ] | |||||||||||||||||||||
|
see also https://github.com/sqlalchemy/sqlalchemy/issues/10396 | |||||||||||||||||||||
| Comment by Georg Richter [ 2023-09-29 ] | |||||||||||||||||||||
|
It's not really a fix but a workaround for pandas: Instead of raising an exception when accessing rowcount property after cursor was closed, rowcount now returns -1. This should also be in accordance to PEP-249: | |||||||||||||||||||||
| Comment by Marshall [ 2023-10-11 ] | |||||||||||||||||||||
|
George - I see the fix version is listed as 1.1.8 - has this been released yet? tried to upgrade via pip but that version isn't listed as available | |||||||||||||||||||||
| Comment by Georg Richter [ 2023-10-11 ] | |||||||||||||||||||||
|
I'm just finishing |