GitDB Python SDK
Official Python client for GitDB - GitHub-backed NoSQL database.
Features
- 🚀 Easy to use - Familiar MongoDB-like API
- 🔗 Connection management - Automatic reconnection and health checks
- 📊 GraphQL support - Full GraphQL client with introspection
- 🔒 Type safety - Full type hints and Pydantic models
- ⚡ Async support - Modern async/await API
- 🛡️ Error handling - Comprehensive error types and handling
- 🔧 Flexible configuration - Environment variables and custom config
Installation
pip install gitdb-client
Quick Start
Basic Usage
import asyncio
from gitdb import GitDB
async def main():
# Initialize client
db = GitDB.from_environment()
# Connect and use
await db.connect()
users = db.collection('users')
# Insert a document
user = await users.insert({
'name': 'John Doe',
'email': 'john@example.com',
'age': 30
})
# Find documents
all_users = await users.find()
john = await users.find_one({'name': 'John Doe'})
# Update document
await users.update(user['document']['_id'], {'age': 31})
# Delete document
await users.delete(user['document']['_id'])
await db.disconnect()
# Run the example
asyncio.run(main())
Environment Variables
import os
# Set environment variables
os.environ['GITDB_TOKEN'] = 'ghp_your_github_token_here'
os.environ['GITDB_OWNER'] = 'your-username'
os.environ['GITDB_REPO'] = 'your-database-repo'
os.environ['GITDB_HOST'] = 'localhost'
os.environ['GITDB_PORT'] = '7896'
# Use from environment
db = GitDB.from_environment()
API Reference
GitDB Client
Constructor
GitDB(config: GitDBConfig)
Config Options:
token(required): GitHub personal access tokenowner(required): GitHub username or organizationrepo(required): GitHub repository namehost(optional): GitDB server host (default: 'localhost')port(optional): GitDB server port (default: 7896)timeout(optional): Request timeout in ms (default: 30000)retries(optional): Number of retry attempts (default: 3)
Methods
# Connection management
await db.connect(): None
await db.disconnect(): None
db.is_connected(): bool
await db.get_status(): ConnectionStatus
await db.ping(): bool
await db.health(): Any
# Collection management
db.collection(name: str): Collection
await db.list_collections(): List[str]
await db.create_collection(name: str): None
await db.delete_collection(name: str): None
# Utility methods
await db.use_collection(name: str): Collection
# Static methods
GitDB.from_environment(): GitDB
GitDB.from_config(config: GitDBConfig): GitDB
Collection API
Methods
# Create operations
await collection.insert(document: Dict[str, Any]): Dict[str, Any]
# Read operations
await collection.find(query: Optional[Dict[str, Any]] = None): Dict[str, Any]
await collection.find_one(query: Optional[Dict[str, Any]] = None): Optional[Dict[str, Any]]
await collection.find_by_id(id: str): Optional[Dict[str, Any]]
await collection.count(query: Optional[Dict[str, Any]] = None): int
# Update operations
await collection.update(id: str, update: Dict[str, Any]): Dict[str, Any]
# Delete operations
await collection.delete(id: str): Dict[str, Any]
Examples
See the examples/ directory for complete working examples:
basic_test.py- Basic connection and operationscrud_test.py- CRUD operationsgraphql_test.py- GraphQL queries and mutations
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details.
Metadata
Release files for gitdb-client 1.0.0
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 |
|---|---|---|---|---|
| gitdb_client-1.0.0.tar.gz | 9.6 kB | Without provenance | Details for gitdb_client-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gitdb_client-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for gitdb_client-1.0.0-py3-none-any.whl |
Total release size: 18.3 kB
Release files / gitdb_client-1.0.0.tar.gz
| Download URL | gitdb_client-1.0.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7c178d44dd854dbe9e7217396bdaad389d9c9c5685ea4a12830a5c6875b9f77
|
|
BLAKE2b-256 checksum How to use checksums |
8d6a21d133af783cf634ba7cd3ca6d99b5b2d1faa8425fa9ab0580f2c26a3754
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Release files / gitdb_client-1.0.0-py3-none-any.whl
| Download URL | gitdb_client-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91b0936b5021817b35e1157e28ddddfe7af41dbf82522793e34d4ae995b117fd
|
|
BLAKE2b-256 checksum How to use checksums |
f9b88e3e85579991be452f37a961eb768d31a23a8e1cf2a00a3819af222c8b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.5
|
Security for gitdb-client 1.0.0
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.