> For the complete documentation index, see [llms.txt](https://shsbt.gitbook.io/hack-with-data/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shsbt.gitbook.io/hack-with-data/working-with-data/example-of-querying-data-from-python.md).

# Example of Querying Data from Python

```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.

{% hint style="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.py>
{% endhint %}
