Whenever i do a insert with db.(table).insert in an async function that is managed by asyncio i seem to get an ValueError.
I am not 100% sure why this occurs but i do know this only happend withing the async function run_taak(), see run_taak code.
I tried this without the asyncio and it seemed to be working fine. Is this due to the framework not supporting async db insert's(which would be strange bc even if the insert is async the db should still be able to do it sync)?? Or am i not able to use asyncio for db insert's(if not is there any other lib I can use that supports the same functionality?)
import asyncio
async def run(user_id):
loop = asyncio.get_event_loop()
for task in tasks:
tasks = db(db.taak.id > 0).select(db.taak.id, db.taak.requirement_id)
# if task.requirement_id is None:
loop.create_task(run_taak(db, task.id, user_id))
I seem to get an value error
emmett_1 | [ERROR] Task exception was never retrieved
emmett_1 | future: <Task finished name='Task-5' coro=<run_taak() done, defined at /app/testem/tools/taak_tools.py:16> exception=ValueError('INSERT INTO "taak_voortgang_response"("request_uuid","ran_ok","body","status_code","nieuweling_id","taak_id") VALUES (\'a\',\'T\',\'test\',200,\'1\',\'1\');')>
emmett_1 | Traceback (most recent call last):
emmett_1 | File "/app/testem/tools/taak_tools.py", line 40, in run_taak
emmett_1 | db.taak_voortgang_response.insert(taak_id=1, body="test", ran_ok=True, request_uuid="a", nieuweling_id=1,
emmett_1 | File "/usr/local/lib/python3.11/site-packages/emmett/orm/objects.py", line 143, in insert
emmett_1 | ret = self._db._adapter.insert(self, row.op_values())
emmett_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
emmett_1 | File "/usr/local/lib/python3.11/site-packages/emmett/orm/adapters.py", line 62, in wrapped
emmett_1 | return f(adapter, *args, **kwargs)
emmett_1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
emmett_1 | File "/usr/local/lib/python3.11/site-packages/emmett/orm/adapters.py", line 139, in insert
emmett_1 | raise e
emmett_1 | File "/usr/local/lib/python3.11/site-packages/emmett/orm/adapters.py", line 134, in insert
emmett_1 | adapter.execute(query)
emmett_1 | File "/usr/local/lib/python3.11/site-packages/pydal/adapters/__init__.py", line 65, in wrap
emmett_1 | raise ValueError(args[1])
emmett_1 | ValueError: INSERT INTO "taak_voortgang_response"("request_uuid","ran_ok","body","status_code","nieuweling_id","taak_id") VALUES ('a','T','test',200,'1','1');
run_taak code:
async def run_taak(db, taak_id, user_id):
db.taak_voortgang_response.insert(taak_id=1, body="test", ran_ok=True, request_uuid="a", nieuweling_id=1,
status_code=200)
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too