Reputation: 6682
This is a minimum code:
import sqlite3 as sq3
import os
import sys
def main(argv):
q = 'select * from table_name;'
db = 'test.db'
con = sq3.connect(db)
cur = con.cursor()
cur.executescript(q) // cur.execute(q) will work
print cur.fetchone()
if __name__ == '__main__':
sys.exit(main(sys.argv))
My problem is executescript
always fails while execute
works fine. Is it because executescript
is Nonstandard or some libraries I missed?
Upvotes: 0
Views: 4239
Reputation: 3520
executescript
isn't supposed to return anything, what would it return? The last statement? The first statement? or maybe that one in the middle.
Since it allows you to execute multiple SQL statements there is no way to tell which one you want to have returned.
Upvotes: 4
Reputation: 184201
executescript()
is for executing multiple SQL commands, i.e., a script. What is the return value of multiple SQL commands? Hard to say, which is why executescript()
returns None
. You're not doing anything wrong nor do you have anything missing in your installation.
Upvotes: 2