Examples Overview¶
Explore practical examples demonstrating Pydantic Airtable capabilities.
Available Examples¶
| Example | Difficulty | Description |
|---|---|---|
| Simple Usage | Beginner | Basic CRUD operations and field type detection |
| Table Management | Intermediate | Schema creation and synchronization |
| Agentic Researcher | Advanced | AI-powered research assistant with OpenAI |
Quick Links¶
Getting Started¶
Start with the Simple Usage example to learn:
- How to define models with the
@airtable_modeldecorator - Field type detection
- Basic CRUD operations
- Environment-based configuration
Schema Management¶
The Table Management example covers:
- Creating tables from Pydantic models
- Field type customization
- Schema synchronization
- Handling model evolution
AI Integration¶
The Agentic Researcher shows:
- Complex multi-model applications
- OpenAI GPT-4 integration
- Real-time web search
- Structured research workflows
Running Examples¶
Prerequisites¶
All examples require:
- Python 3.8+
- Airtable credentials:
- Personal Access Token (PAT)
- Base ID
Setup¶
-
Clone the repository:
-
Install dependencies:
-
Create
.envfile:
Run¶
Example Code Snippets¶
Basic Model¶
from pydantic_airtable import airtable_model, configure_from_env
from pydantic import BaseModel
configure_from_env()
@airtable_model(table_name="Tasks")
class Task(BaseModel):
title: str
completed: bool = False
# Create
task = Task.create(title="Learn Pydantic Airtable")
# Read
tasks = Task.all()
# Update
task.completed = True
task.save()
# Delete
task.delete()
With Field Type Detection¶
@airtable_model(table_name="Contacts")
class Contact(BaseModel):
name: str # → SINGLE_LINE_TEXT
email: str # → EMAIL (detected)
phone: str # → PHONE (detected)
website: str # → URL (detected)
bio: str # → LONG_TEXT (detected)
With Custom Fields¶
from pydantic_airtable import airtable_field, AirtableFieldType
@airtable_model(table_name="Products")
class Product(BaseModel):
name: str
status: str = airtable_field(
field_type=AirtableFieldType.SELECT,
choices=["Draft", "Active", "Discontinued"]
)
price: float = airtable_field(
field_name="Price (USD)",
field_type=AirtableFieldType.CURRENCY
)
Learning Path¶
Recommended order:
- Simple Usage - Foundation concepts
- Table Management - Schema management
- Agentic Researcher - Real-world application
Each example builds on concepts from previous ones.
Next Steps¶
After exploring examples:
- Read the User Guide for detailed documentation
- Check Advanced Topics for complex scenarios
- Review API Reference for complete API documentation