Quick Start¶
Get up and running with CinchDB in 5 minutes.
⚠️ NOTE: CinchDB is in early alpha. This is a project to test out an idea. Do not use this in production.
Initialize Your First Project¶
# Create a new CinchDB project
cinch init myapp
cd myapp
# List databases (shows 'main' by default)
cinch db list
Create Your First Table¶
# Create a users table
cinch table create users name:TEXT email:TEXT age:INTEGER
# View the table structure
cinch table info users
Every table automatically includes:
- id
- UUID primary key
- created_at
- Creation timestamp
- updated_at
- Last update timestamp
Insert and Query Data¶
# Insert data
cinch insert users --data '{"name": "Alice", "email": "alice@example.com", "age": 30}'
# Query data
cinch query "SELECT * FROM users"
Work with Branches¶
# Create a feature branch
cinch branch create add-products
# Switch to the new branch
cinch branch switch add-products
# Add a products table
cinch table create products name:TEXT price:REAL category:TEXT
# Switch back to main
cinch branch switch main
# Merge changes
cinch branch merge-into-main add-products
Multi-Tenant Operations¶
# Create a new tenant
cinch tenant create customer_a
# Query tenant-specific data
cinch query "SELECT * FROM users" --tenant customer_a
# Insert data for a specific tenant
cinch insert users --tenant customer_a --data '{"name": "Bob", "email": "bob@customer-a.com"}'
Python SDK Usage¶
import cinchdb
from cinchdb.models import Column
# Connect to your database
db = cinchdb.connect("myapp")
# Create a table
db.create_table("posts", [
Column(name="title", type="TEXT"),
Column(name="content", type="TEXT"),
Column(name="published", type="BOOLEAN", nullable=True)
])
# Insert data
post = db.insert("posts", {
"title": "Hello CinchDB",
"content": "This is my first post",
"published": True
})
# Query data
posts = db.query("SELECT * FROM posts WHERE published = ?", [True])
for post in posts:
print(f"{post['title']}: {post['content']}")
# Work with branches
dev_db = cinchdb.connect("myblog", branch="development")
dev_db.create_table("comments", [
Column(name="post_id", type="TEXT"),
Column(name="content", type="TEXT")
])
Generate SDK from Your Schema¶
# After creating tables, generate a type-safe SDK
cinch codegen generate python models/
# Use the generated SDK
from models import cinch_models
# Connect and use your models
db = cinchdb.connect("myapp")
models = cinch_models(db)
# Type-safe CRUD operations
user = models.User.create(name="Alice", email="alice@example.com", age=30)
all_users = models.User.get_all()
models.User.update(user["id"], age=31)
Next Steps¶
- Core Concepts - Understand CinchDB's architecture
- CLI Reference - Complete command documentation
- Python SDK - Full SDK documentation
- Code Generation - Generate SDKs from your schema