SheetSandbox SDK for Python
A simple and easy-to-understand Python SDK for SheetSandbox - Turn Google Sheets into your production-ready database.
🎯 Features
- ✅ Simple & Clean - Easy to understand code without complex parts
- ✅ Basic CRUD Operations - Get, GetById, Post, and Token Verification
- ✅ Pythonic API - Follows Python conventions and best practices
- ✅ Lightweight - Minimal dependencies
- ✅ Ready to Extend - Clean architecture for future enhancements
📦 Installation
pip install sheetsandbox
🚀 Quick Start
from sheetsandbox import SheetSandbox
# Initialize the client
client = SheetSandbox('your-api-token')
# Verify your token
result = client.verify_token()
print(result)
# Create a record
result = client.post('UserFeedback', {
'Subject': 'John Doe',
'Message': 'john@example.com',
'type': 'active'
})
# Get all records
result = client.get('UserFeedback')
# Get a specific record
result = client.get_by_id('UserFeedback', 1)
📖 API Reference
Constructor
client = SheetSandbox(token, base_url=None, timeout=30)
Parameters:
token(str, required) - Your SheetSandbox API tokenbase_url(str, optional) - API base URL (default: 'http://localhost:3001/api')timeout(int, optional) - Request timeout in seconds (default: 30)
Methods
verify_token()
Verify if your API token is valid.
result = client.verify_token()
if result['success']:
print("Token is valid!")
else:
print(f"Error: {result['error']}")
Returns: dict
success(bool) - Operation statusdata(dict) - Verification response datastatus(str) - 'success' or 'error'error(str) - Error message (if failed)
get(table_name)
Get all records from a table.
result = client.get('UserFeedback')
if result['success']:
for record in result['data']:
print(record)
Returns: dict
success(bool) - Operation statusdata(list) - Array of recordsstatus(str) - 'success' or 'error'error(str) - Error message (if failed)
get_by_id(table_name, record_id)
Get a specific record by ID.
result = client.get_by_id('UserFeedback', 1)
if result['success']:
print(result['data']) # Single record
Parameters:
table_name(str) - Name of the tablerecord_id(int|str) - Record ID (1-based index)
Returns: dict
success(bool) - Operation statusdata(dict) - Record datastatus(str) - 'success' or 'error'error(str) - Error message (if failed)
post(table_name, data)
Create a new record.
result = client.post('UserFeedback', {
'Subject': 'Feature Request',
'Message': 'Add dark mode support',
'type': 'feature'
})
if result['success']:
print('Record created!')
Parameters:
table_name(str) - Name of the tabledata(dict) - Record data to create
Returns: dict
success(bool) - Operation statusdata(dict) - Created record datastatus(str) - 'success' or 'error'error(str) - Error message (if failed)
set_token(new_token)
Update the API token.
client.set_token('new-api-token')
set_base_url(new_base_url)
Update the base URL.
client.set_base_url('https://api.sheetsandbox.com')
get_config()
Get current configuration.
config = client.get_config()
print(config)
# {'base_url': '...', 'timeout': 30, 'has_token': True}
💡 Examples
Waitlist Signup
from sheetsandbox import SheetSandbox
from datetime import datetime
client = SheetSandbox('your-api-token')
def add_to_waitlist(email, name):
result = client.post('Waitlist', {
'email': email,
'name': name,
'timestamp': datetime.now().isoformat()
})
if result['success']:
print('✅ Added to waitlist!')
else:
print(f"❌ Error: {result['error']}")
add_to_waitlist('user@example.com', 'Jane Doe')
Feedback Form
def submit_feedback(feedback):
result = client.post('Feedback', {
'message': feedback['message'],
'rating': feedback['rating'],
'email': feedback['email'],
'submitted_at': datetime.now().isoformat()
})
return result['success']
# Usage
feedback_data = {
'message': 'Great product!',
'rating': 5,
'email': 'happy@customer.com'
}
if submit_feedback(feedback_data):
print('Feedback submitted successfully!')
Get User Feedback List
def get_feedback_list():
result = client.get('UserFeedback')
if result['success']:
for feedback in result['data']:
print(f"{feedback['Subject']} - {feedback['Message']}")
else:
print(f"Error: {result['error']}")
get_feedback_list()
Token Verification
def check_token():
result = client.verify_token()
if result['success']:
print('✅ Token is valid and working!')
print(f"API Response: {result['data']}")
else:
print(f"❌ Token verification failed: {result['error']}")
check_token()
Complete CRUD Example
from sheetsandbox import SheetSandbox
client = SheetSandbox('your-api-token')
# Verify token first
if not client.verify_token()['success']:
print("Invalid token!")
exit()
# Create a new user
new_user = client.post('Users', {
'name': 'Alice Johnson',
'email': 'alice@example.com',
'role': 'developer'
})
if new_user['success']:
print(f"Created user: {new_user['data']}")
# Get all users
all_users = client.get('Users')
if all_users['success']:
print(f"Total users: {len(all_users['data'])}")
# Get specific user
user = client.get_by_id('Users', 1)
if user['success']:
print(f"First user: {user['data']}")
🔧 Error Handling
All methods return a consistent response format:
result = client.get('Users')
if result['success']:
# Operation succeeded
print(result['data'])
else:
# Operation failed
print(result['error'])
Exception Handling
try:
result = client.post('Users', {
'name': 'Test User',
'email': 'test@example.com'
})
if result['success']:
print('Success!')
else:
print(f"API Error: {result['error']}")
except Exception as e:
print(f"Unexpected error: {str(e)}")
🛣️ Roadmap
This is a simplified version designed to be easy to understand and extend. Future enhancements may include:
- Async/await support with
asyncio - Batch operations (create multiple records at once)
- Advanced filtering and sorting
- Duplicate prevention
- Update and delete operations
- Pagination support
- Retry logic with exponential backoff
- Type hints and better IDE support
- Data validation
📝 License
MIT
🔗 Links
💬 Support
For issues and questions, please visit our GitHub Issues.
🐍 Python Version Support
- Python 3.7+
- Tested on Python 3.8, 3.9, 3.10, 3.11, and 3.12
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Metadata
Release files for sheetsandbox 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sheetsandbox-1.0.2.tar.gz | 10.6 kB | Without provenance | Details for sheetsandbox-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sheetsandbox-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for sheetsandbox-1.0.2-py3-none-any.whl |
Total release size: 19.3 kB
Release files / sheetsandbox-1.0.2.tar.gz
| Download URL | sheetsandbox-1.0.2.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1c810f5ce5a71ca66d1dd8a55e7dc4ec793f86151ba19d41f350efa85e679a5
|
|
BLAKE2b-256 checksum How to use checksums |
99e0b8fb047a30bbc0a4b7ca903a9e47cc3072ebc59c5b637440c1b2b00d6823
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / sheetsandbox-1.0.2-py3-none-any.whl
| Download URL | sheetsandbox-1.0.2-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c3962e3c3ff9bcf80f25c2ced76efabfc7c3678f92038a89ea229e231521e88
|
|
BLAKE2b-256 checksum How to use checksums |
da49942431b0b5844965b3831ce837b5a31fa661d4c77f685ab5c6fec38df1be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for sheetsandbox 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.