SQL
Full SQLite access over HTTP. Create tables, run joins, add indexes, use transactions, full-text search (FTS5), and parameterized queries.
1. Create a database
from cinchdb import Cinch
client = Cinch(api_key="ck_live_...", org="acme")
scope = client.scope("my-app", environment="production", project="api")
db = scope.create_database(type="sql", name="main")2. Run SQL
Send SQL over HTTP with Bearer token auth. Two endpoints:
| Single | POST https://http.cinchdb.dev/v1/sql |
| Batch | POST https://http.cinchdb.dev/v1/sql/batch |
| Auth | Authorization: Bearer <token> |
import requests
ENDPOINT = "https://http.cinchdb.dev/v1/sql"
TOKEN = "YOUR_DATABASE_TOKEN"
HEADERS = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
}
def query(sql, params=None):
body = {"sql": sql}
if params:
body["params"] = params
return requests.post(ENDPOINT, json=body, headers=HEADERS).json()
# Create a table
query("CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)")
# Insert
query("INSERT INTO users (name, email) VALUES (?, ?)", ["Alice", "alice@example.com"])
# Query
result = query("SELECT * FROM users")
print(result)i
Good to know
- Parameterized queries: use
?for positional or:namefor named params. - Max 256 statements per batch.
- 5 second timeout per query (protects against expensive joins or recursive CTEs).
- ATTACH DATABASE and extension loading are blocked for security.
- Read-only tokens cannot run INSERT, UPDATE, DELETE, or DDL.
See SQL Reference for the full list of supported features, types, and limitations.