'How to get current information in asyncio function?
I have an asynchronous function where I query the database. My main task is to get up-to-date information from this asynchronous function. I understand that when I call the function it passes only those values that were at the time of launch, but how to update them when they are updated in the database?
code:
import asyncio
import aiosqlite
async def connection_db():
db = await aiosqlite.connect('register.db')
cursor = await db.execute('SELECT * FROM users ORDER BY time DESC')
rows = await cursor.fetchall()
await db.commit()
await db.close()
return rows
loop = asyncio.get_event_loop()
rows = loop.run_until_complete(connection_db())
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
