πŸ“±Example of Querying Data from Python

import sqlite3

con = sqlite3.connect('thenameofyoursqlitedatabase.db')

cursor = con.cursor()

resultset = cursor.execute("SELECT * FROM yourtablename")

for row in resultset:
  print(row)

You can see the SQL code embedded in the Python code above. Essentially, the Python code is making a connection to the database and running the SQL code that the programmer specified.

circle-info

If you want to play with this example on your own, feel free to fork and run this code sample at: https://replit.com/@gsantella/sqlite#main.pyarrow-up-right

Last updated