Python SDK
Complete guide to using Cocobase with Python applications and Cloud Functions.Installation
Quick Start
Initialize Cocobase
Basic Operations
Querying Data
Simple Filters
Query Builder
Operators Reference
Comparison Operators
| Operator | Filter Key | Example |
|---|---|---|
| Equal | field | {"status": "active"} |
| Greater Than | field__gt | {"age__gt": 18} |
| Greater or Equal | field__gte | {"age__gte": 18} |
| Less Than | field__lt | {"age__lt": 65} |
| Less or Equal | field__lte | {"age__lte": 65} |
| Not Equal | field__ne | {"status__ne": "deleted"} |
String Operators
| Operator | Filter Key | Example |
|---|---|---|
| Contains | field__contains | {"title__contains": "python"} |
| Starts With | field__startswith | {"email__startswith": "admin"} |
| Ends With | field__endswith | {"domain__endswith": ".com"} |
Array Operators
| Operator | Filter Key | Example |
|---|---|---|
| In Array | field__in | {"status__in": "active,pending"} |
| Not In Array | field__notin | {"status__notin": "deleted,archived"} |
Sorting and Pagination
Sorting
Pagination
Working with Dataclasses
Define Your Types
Create with Dataclasses
Parse Response to Dataclass
Authentication
Email/Password
OAuth
Advanced Auth
Register with Files
Update User
Update User with Files
Two-Factor Authentication (2FA)
Role Checking
List Users
Get User by ID
Cloud Functions
The Python SDK is primarily used in Cocobase Cloud Functions.Basic Cloud Function
Triggered Cloud Function
Scheduled Cloud Function
Error Handling
Best Practices
1. Use Dataclasses for Type Safety
2. Always Handle Errors
3. Use Environment Variables
4. Always Set Limits
Next Steps
- Cloud Functions - Build serverless functions
- JavaScript SDK - Learn about the JS/TS SDK
- Flutter SDK - Learn about the Flutter SDK
- Authentication - Deep dive into auth
