Skip to content
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

ValueError: could not convert string to float #47

Open
Trolldemorted opened this issue Oct 27, 2022 · 2 comments
Open

ValueError: could not convert string to float #47

Trolldemorted opened this issue Oct 27, 2022 · 2 comments

Comments

@Trolldemorted
Copy link

Given this extremely simple example:

source_engine = create_async_engine(
    f"mysql+asyncmy://{user}:{password}@{host}:{port}/{database}?charset=utf8",
    echo=True)

handled_rows = 0
lower_bound = 1_000_000 * int(sys.argv[1])
upper_bound = 1_000_000 + lower_bound
async with source_engine.begin() as conn:
    async for row in await conn.stream(text(f"SELECT * FROM {table} WHERE {lower_bound} <= ID AND ID < {upper_bound};")):
        handled_rows += 1
        if handled_rows % 10000 == 0:
            logger.info(f"{lower_bound} - {upper_bound} handled {handled_rows}")

in a fresh venv with these dependencies:

asyncmy==0.2.5
greenlet==1.1.3.post0
SQLAlchemy==1.4.42

I sometimes get this ValueError:

2022-10-27 10:42:50,471 INFO sqlalchemy.engine.Engine ROLLBACK
2022-10-27 10:42:50,471 INFO MainThread - sqlalchemy.engine.Engine:1055 _rollback_impl -- ROLLBACK
Traceback (most recent call last):
  File "test.py", line 55, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
    return future.result()
  File "test.py", line 50, in main
    async for row in await conn.stream(text(f"SELECT * FROM {table} WHERE {lower_bound} <= ID AND ID < {upper_bound};")):
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/ext/asyncio/result.py", line 174, in __anext__
    row = await greenlet_spawn(self._onerow_getter, self)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 128, in greenlet_spawn
    result = context.switch(value)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 457, in onerow
    row = self._fetchone_impl()
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 1340, in _fetchone_impl
    return self._real_result._fetchone_impl(hard_close=hard_close)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1816, in _fetchone_impl
    return self.cursor_strategy.fetchone(self, self.cursor, hard_close)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1096, in fetchone
    self._buffer_rows(result, dbapi_cursor)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1068, in _buffer_rows
    self.handle_exception(result, dbapi_cursor, e)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 955, in handle_exception
    result.connection._handle_dbapi_exception(
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 2128, in _handle_dbapi_exception
    util.raise_(exc_info[1], with_traceback=exc_info[2])
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/engine/cursor.py", line 1066, in _buffer_rows
    new_rows = dbapi_cursor.fetchmany(size)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/asyncmy.py", line 169, in fetchmany
    return self.await_(self._cursor.fetchmany(size=size))
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 68, in await_only
    return current.driver.switch(awaitable)
  File "/foo/.venv2/lib/python3.8/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 121, in greenlet_spawn
    value = await result
  File "asyncmy/cursors.pyx", line 515, in fetchmany
  File "asyncmy/cursors.pyx", line 482, in read_next
  File "asyncmy/connection.pyx", line 1116, in _read_rowdata_packet_unbuffered
  File "asyncmy/connection.pyx", line 1157, in asyncmy.connection.MySQLResult._read_row_from_packet
ValueError: could not convert string to float: '751>2402'

Any clue what might be happening?

@long2ice
Copy link
Owner

Can you show the table struct and the real data in it?

@Trolldemorted
Copy link
Author

Unfortunately not, the data is sensitive and I didn't have the time to reproduce it with dummy data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants