-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Packet sequence number wrong with sqlalchemy + mysql with zero dates #101
Comments
same problem |
@max1mn 换 aiomysql 可以 |
asyncmy cannot handle zero dates properly. import asyncio
import asyncmy
async def main():
conn = await asyncmy.connect(...)
async with conn.cursor() as cur:
await cur.execute("SELECT * FROM asyncmy WHERE id=1")
result = await cur.fetchall()
conn.close()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Zero dates allowed by MySQL are invalid in python datetime. PyMySQL and aiomysql handles this issue by returning invalid datetime as str. asyncmy reuses PyMySQL's codes in asyncmy/asyncmy/converters.pyx Line 253 in 161b2dd
It seems that this issue causes sqlalchemy to skip the packet without adding the sequence number, which result in wrong packet number. |
Thanks! Could you make a PR to fix that? |
@long2ice I've changed return type of |
strangely i get the packet sequence wrong with im sorry to do this. mind just checking if |
I cannot reproduce it in 0.2.9. Could you provide a minimum example? |
im sorry :( found the issue seems that when an issue occurs while looping through the records and trying to insert it to a pydantic model and theres an error... yet when you scroll aaaalllll the way to the top above all the this is caused by that exception stuff is the actual error. so seems in my case while the mysql connection is open and theres a pydantic error thrown in a fastapi app it probably doesnt close the connection or does something strange to it. i originally thought it was the date fields cause if i remove them from the query it works. add them in and asyncmy complains about packets. so my minimal app sometimes worked and sometimes didnt again lol again. sorry for wasting your time! |
Hello,
When NO_ZERO_DATE is set in mysql and there are rows with zero dates, driver fails with "Packet sequence number wrong" error. Please see complete example below
init.sql
docker-compose.yml
requirements.txt
main.py
The text was updated successfully, but these errors were encountered: