Difference between revisions of "Select sqlite queries"
(Created page with "You need to ensure you have followed the tutorial to create a database connection. =Python Code= The 'create', 'update', 'insert', and 'delete' queries only require execution...") |
(No difference)
|
Latest revision as of 10:38, 6 October 2019
You need to ensure you have followed the tutorial to create a database connection.
Python Code
The 'create', 'update', 'insert', and 'delete' queries only require execution, however the 'select' query needs to return values. So add the following
def select_query(conn, sql):
cur = conn.cursor()
cur.execute(sql)
rows = cur.fetchall()
for row in rows:
print(row)
you can therefore run:
select_query("Select * from table")