Docs
SDKs

Python SDK

Use silos-sdk-python to manage databases and branches and run SQL from Python.

The Python SDK (silos-sdk-python) lets you provision and manage Silos databases and branches from Python, and run SQL against them. It wraps the same management API used by the Console and CLI.

The Python SDK is available and evolving. The snippet below shows the minimal install-and-connect path. For authoritative request and response shapes, see the API reference.

Install

Terminal
pip install silos-sdk

Initialize the client

Read your API key from the environment and construct a client.

provision.py
import os
from silos import Silos

silos = Silos(api_key=os.environ["SILOS_API_KEY"])

# Create a database
db = silos.databases.create(name="my-app")

# Branch it for a preview or test environment
branch = silos.branches.create(database=db.name, name="preview")

# Tear it down when you're done
silos.branches.delete(database=db.name, name="preview")

Method and parameter names track the management API and may change as the SDK matures. The API reference is canonical for the exact surface.

Run SQL with a standard driver

For application data access, the simplest path is a standard Postgres driver such as psycopg, using the database's connection string. Silos speaks the Postgres wire protocol, so no Silos-specific driver is required.

query.py
import os
import psycopg

with psycopg.connect(os.environ["SILOS_DATABASE_URL"]) as conn:
    with conn.cursor() as cur:
        cur.execute("SELECT id, email FROM users LIMIT 10")
        for row in cur.fetchall():
            print(row)

Your SILOS_DATABASE_URL looks like:

postgres://user:password@db-xxxx.silos.sh/main?sslmode=require

TLS is required — keep sslmode=require. SQLAlchemy and other Postgres-based tools connect with the same URL; see Connecting → Drivers.

Next steps

On this page