Skip to content

Connection.execute doesn't accept list for placeholder values, unlike sqlite3 #17

Open
@egerke28

Description

@egerke28

The following executes successfully in sqlite3:

import sqlite3

dbconn = sqlite3.connect("db.sqlite")
dbconn.execute("CREATE TABLE test (first int, second int, third int)")
values = [1,2,3]
dbconn.execute("INSERT INTO test VALUES (?,?,?)", values)
dbconn.commit()
result = dbconn.execute("SELECT * FROM test").fetchall()
print (result)

Prints out
[(1, 2, 3)]

However creating the analogous code in asqlite:

import asqlite
import asyncio

async def foo():
    dbconn = await asqlite.connect("db.sqlite")
    await dbconn.execute("CREATE TABLE test (first int, second int, third int)")
    values = [1,2,3]
    await dbconn.execute("INSERT INTO test VALUES (?,?,?)", values)
    await dbconn.commit()
    cur = await dbconn.execute("SELECT * FROM test")
    result = await cur.fetchall()
    print (result)

asyncio.run(foo())

Throws:
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 3, and there are 1 supplied.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions