Turso Database Getting Started Connect
Connect to Turso using Python
Connect to Turso using Python — Turso documentation.
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) Synced from official Turso documentation (
tursodatabase/turso-docs
· MIT License)
Official Docs ↗