1

Install

Add the Turso package to your Python project:
uv pip install pyturso
2

Connect

Here’s how you can connect to a local SQLite database:
import turso

con = turso.connect("sqlite.db")
cur = con.cursor()
3

Create table

Create a table for users:
cur.execute("""
  CREATE TABLE IF NOT EXISTS users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT NOT NULL
  )
""")
con.commit()
4

Insert data

Insert some data into the users table:
cur.execute("INSERT INTO users (username) VALUES (?)", ("alice",))
cur.execute("INSERT INTO users (username) VALUES (?)", ("bob",))
con.commit()
5

Query data

Query all users from the table:
res = cur.execute("SELECT * FROM users")
users = res.fetchall()
print(users)