sqlite3
ProgrammingError
Python
SQL
error-handling

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

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

The SQLite error saying “statement uses 1, and there are 74 supplied” almost always means one parameter was expected, but Python interpreted your input as many separate values. The most common case is passing a string directly instead of a one-element tuple. The fix is to supply parameters in the exact structure expected by the DB-API binding rules.

Why SQLite Reports 74 Bindings

In Python sqlite3, query placeholders are bound from a sequence or mapping. A plain string is also a sequence, so SQLite treats each character as a separate value. If the string length is 74, you get the exact error with 74 supplied.

Broken pattern:

python
cursor.execute("INSERT INTO users(name) VALUES (?)", "alice")

SQLite expected one binding, but it received five characters in this small example.

Correct Single-Parameter Binding

Use a one-item tuple with a trailing comma.

python
1import sqlite3
2
3conn = sqlite3.connect(":memory:")
4cur = conn.cursor()
5cur.execute("CREATE TABLE users(name TEXT)")
6
7name = "alice"
8cur.execute("INSERT INTO users(name) VALUES (?)", (name,))
9conn.commit()
10
11cur.execute("SELECT name FROM users")
12print(cur.fetchall())

The trailing comma is mandatory for a tuple of length one.

Multi-Parameter and Named Bindings

For multiple placeholders, align count and order exactly.

python
1cur.execute(
2    "INSERT INTO users(name, age) VALUES (?, ?)",
3    ("bob", 31),
4)

Named placeholders reduce ordering mistakes:

python
1cur.execute(
2    "INSERT INTO users(name, age) VALUES (:name, :age)",
3    {"name": "carol", "age": 29},
4)

Both forms are safe when parameter structures match query placeholders.

Batch Inserts With executemany

When inserting many rows, pass a list of tuples.

python
rows = [("dave", 22), ("erin", 27), ("frank", 35)]
cur.executemany("INSERT INTO users(name, age) VALUES (?, ?)", rows)
conn.commit()

Do not pass a flat list for multi-column statements.

IN Clause Special Case

A related binding issue appears with dynamic IN filters. You must generate a matching number of placeholders.

python
1ids = [2, 5, 8]
2placeholders = ",".join("?" for _ in ids)
3sql = f"SELECT id, name FROM users WHERE id IN ({placeholders})"
4cur.execute(sql, ids)
5print(cur.fetchall())

If placeholder count and list length differ, you get another bindings error.

Debugging Checklist

When you hit binding errors, inspect both SQL and parameters:

  • Count placeholders in the SQL string
  • Print type(params) and sample values
  • For one value, verify tuple syntax includes trailing comma
  • Confirm executemany input is an iterable of row tuples
  • Prefer named bindings for long statements

A quick assertion helps:

python
sql = "INSERT INTO users(name) VALUES (?)"
params = ("grace",)
assert sql.count("?") == len(params)

Security Reminder

Always use parameterized queries and never build SQL with string concatenation.

python
unsafe = "alice' OR 1=1 --"
# wrong: f"SELECT * FROM users WHERE name = '{unsafe}'"
cur.execute("SELECT * FROM users WHERE name = ?", (unsafe,))

Parameterization solves both correctness and SQL injection risk.

Common Pitfalls

  • Forgetting the trailing comma in one-item tuples
  • Passing plain strings where sequence parameters are expected
  • Mismatch between placeholder count and tuple length
  • Using executemany with incorrectly shaped row data
  • Mixing placeholder styles in one statement

Most binding errors are fixed quickly once parameter shape is inspected.

Summary

  • The “1 used, 74 supplied” message usually means a string was treated as many values.
  • For one placeholder, pass a one-item tuple like (value,).
  • Keep placeholder count aligned with parameter count.
  • Use named bindings for readability in larger statements.
  • Parameterized queries improve both reliability and security.

Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design