NotionDBRS 🦀
A high-performance Notion database client built with Rust and exposed to Python via PyO3. Handles bulk data operations efficiently with parallel processing.
Features
- Rust-powered backend with Tokio async runtime for parallel operations
- Smart data merging - only uploads new/changed records
- Bulk operations - efficiently handle large datasets
- Dynamic database creation - create Notion databases programmatically
- Type-safe - comprehensive error handling across Python-Rust boundary
Installation
# from pypi
pip install notiondbrs
# Clone and build
git clone https://github.com/yourusername/notiondbrs.git
cd notiondbrs
chmod +x run.sh
./run.sh
Configuration
Create a .env file:
NOTION_TOKEN=your_notion_integration_token
DB_ID=your_database_id
PAGE_ID=your_page_id # For creating new databases
Usage
Basic Setup
from notion_utils import NotionClient
import os
from dotenv import load_dotenv
load_dotenv()
client = NotionClient(os.environ.get("NOTION_TOKEN"))
List Databases
databases = client.get_all_databases()
for db_id, db_name in databases:
print(f"{db_name}: {db_id}")
Get Data from Database
data = client.get_data_from_database("your-database-id")
print(f"Retrieved {len(next(iter(data.values())))} rows")
print(f"Columns: {list(data.keys())}")
Bulk Data Upload
import uuid
import random
import time
# Prepare data
upload_data = {
"name": [f"Item_{i}" for i in range(1000)],
"id": [str(uuid.uuid4()) for _ in range(1000)],
"value": [str(random.randint(1, 1000)) for _ in range(1000)]
}
# Upload with timing
start_time = time.time()
client.insert_data(upload_data, "your-database-id")
duration = time.time() - start_time
print(f"Uploaded 1000 rows in {duration:.2f} seconds")
print(f"Throughput: {1000/duration:.0f} rows/second")
Smart Data Merging
# Only new records will be uploaded
merge_data = {
"name": ["Existing_Item", "New_Item_1", "New_Item_2"],
"id": ["existing-123", "new-456", "new-789"],
"value": ["100", "200", "300"]
}
client.merge_data(merge_data, "your-database-id")
Create New Database
new_data = {
"title": ["Entry 1", "Entry 2"],
"status": ["Active", "Pending"],
"date": ["2024-01-01", "2024-01-02"]
}
# Creates database and uploads data
client.insert_data(new_data, "your-page-id", new_db=True)
Performance
Typical performance on standard datasets:
| Records | Time |
|---|---|
| 100 | ~8s |
| 1,000 | ~30s |
| Data Retrieval | <1s |
Architecture
The Rust backend uses Tokio for async parallel processing while maintaining a simple Python interface:
# Python layer - simple and clean
client.insert_data(data, db_id)
# Rust layer handles:
# - Parallel HTTP requests
# - Memory-efficient data processing
# - Error handling and retries
Development
Project Structure
src/ # Rust implementation
├── lib.rs # PyO3 module
├── notion_class.rs # Python interface
├── notion_utils.rs # Core API logic
└── utils.rs # Data processing
notiondbrs-py/ # Python wrapper
├── examples.py # Usage examples
└── notion_utils.py # Python interface
Building
# Development build
maturin develop
# Release build (optimized)
maturin develop --release
License
MIT License
Metadata
Release files for notiondbrs 0.1.1
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 |
|---|---|---|---|---|
| notiondbrs-0.1.1.tar.gz | 26.5 kB | Without provenance | Details for notiondbrs-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| notiondbrs-0.1.1-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details for notiondbrs-0.1.1-cp313-cp313-macosx_11_0_arm64.whl |
Total release size: 2.1 MB
Release files / notiondbrs-0.1.1.tar.gz
| Download URL | notiondbrs-0.1.1.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a5ffcaa1495cea3cfcc335469b9bb771abd94a81044eca897fbdc7c97deec20
|
|
BLAKE2b-256 checksum How to use checksums |
9e2fef4c1d524100ed5b59d44b8c7ec355dbeb86e786b84f2df04093ef2d557d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / notiondbrs-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | notiondbrs-0.1.1-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d5d322cccc4b541ebbee4ee4ab0a38070910de28292799c87ada8276f1748f3f
|
|
BLAKE2b-256 checksum How to use checksums |
a040432caf3408c950ec26c34711c081fd09e44d21163dd86dd2d9dc3bb73d47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for notiondbrs 0.1.1
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.