Skip to content
Prev Previous commit
Next Next commit
Add test for too many SQL variables
  • Loading branch information
Erlend E. Aasland committed Nov 2, 2021
commit d68d6d844ba3be161a548c9574841d746481ab68
7 changes: 7 additions & 0 deletions Lib/test/test_sqlite3/test_dbapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,13 @@ def __getitem__(slf, x):
with self.assertRaises(ZeroDivisionError):
self.cu.execute("select name from test where name=?", L())

def test_execute_too_many_params(self):
category = sqlite.SQLITE_LIMIT_VARIABLE_NUMBER
msg = "too many SQL variables"
with cx_limit(self.cx, category=category, limit=1):
with self.assertRaisesRegex(sqlite.OperationalError, msg):
self.cu.execute("insert into test values(?, ?)", (1, 2))

def test_execute_dict_mapping(self):
self.cu.execute("insert into test(name) values ('foo')")
self.cu.execute("select name from test where name=:name", {"name": "foo"})
Expand Down