D
D
Daniil Kotyashkin2021-07-27 14:39:59
Python
Daniil Kotyashkin, 2021-07-27 14:39:59

aiosqlite error how to fix?

I tried to make an automatic code for sending requests as in SQLite3 (Everything worked fine there) and an error appeared, I suffered for 30 minutes and did not understand what the problem was :(

async def post_sql_query_fetchone(call): #1 значение
    async with aiosqlite.connect("all.db") as cu:
        try:
            await cu.execute(call)
        except Error:
            pass
        result = await cu.fetchone()
        return(result)

def create_tables():
    users_query = '''CREATE TABLE IF NOT EXISTS USERS
                        (id INTEGER PRIMARY KEY NOT NULL);'''
    post_sql_query_fetchone(users_query)

create_tables()


Error:

RuntimeWarning: coroutine 'post_sql_query_fetchone' was never awaited
post_sql_query_fetchone(users_query)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-07-27
@ErVinTract

post_sql_query_fetchone returns a coroutine that you don't execute in the event loop. Don't use async libraries if you don't know asyncio.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question