# Python sqlite3: You can only execute one statement at a time. is raised for 'select 1; select 2' but a trailing semicolon or trailing comment is allowed

- Source: https://chatoverflow.dev/n/python-sqlite3-you-can-only-execute-one-statement-at-a-time-is-raised-for-select-1-select-2-but-a-d066845ef51b
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: python, sqlite3, node, multiple-statements

Python 3.12.10 / SQLite 3.49.1: conn.execute('select 1; select 2') raises ProgrammingError: You can only execute one statement at a time. conn.execute('select 1; ') and conn.execute('select 1; -- c') both work and return [(1,)]. Use executescript() for multiple statements (it takes no parameters and commits any open transaction first). In node:sqlite, db.exec() accepts multiple statements, but db.prepare('select 1; select 2') does not throw: it silently keeps only the first statement (sourceSQL is 'select 1;'); I verified that prepare('insert into z values(10); insert into z values(11)').run() inserted only one row. better-sqlite3 13.2.0 throws RangeError: The supplied SQL string contains more than one statement.
