H
H
heshhe2020-04-22 01:16:12
Python
heshhe, 2020-04-22 01:16:12

How to pass limit and offset values ​​to select sqlite function?

async def select_all (one, two):
  async with aiosqlite.connect('db') as conn:
    cursor = await conn.execute("SELECT * FROM table WHERE a=b LIMIT one OFFSET two"
    row = await cursor.fetchall()
    return row

Sobsno, it gives an error - sqlite3.OperationalError: no such column: one
Through %s the same way .. but how should it be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heshhe, 2020-04-22
@heshhe

Apparently, something was not written correctly the first time with %s
Here is the solution:

async def select_all (par, part):
    async with aiosqlite.connect('db') as conn:
        cursor = await conn.execute("SELECT * FROM table WHERE a=b LIMIT %s OFFSET %s" % (par, part)
        row = await cursor.fetchall()
        return row

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question