SiftDB Python Client
The official Python client library for SiftDB HTTP API.
Installation
pip install siftdb
Quick Start
Basic Usage
from siftdb import SiftDBClient
# Create client instance
client = SiftDBClient(
base_url="http://localhost:8080",
default_collection="/path/to/my/collection"
)
# Search for text
results = client.search(
query="function main",
path_filter="**/*.py",
limit=50
)
print(f"Found {results.total_matches} matches in {results.duration_ms}ms")
for hit in results.results:
print(f"{hit.file_path}:{hit.line_number}: {hit.line_content}")
Context Manager Usage
with SiftDBClient(base_url="http://localhost:8080") as client:
results = client.search("error handling")
print(f"Found {len(results.results)} results")
Import Files
# Import files into a collection
import_result = client.import_files(
source_path="/path/to/source",
include_patterns=["**/*.py", "**/*.md"],
exclude_patterns=["**/__pycache__/**", "**/.*"]
)
print(f"Imported {import_result.files_ingested} files")
print(f"Skipped {import_result.files_skipped} files")
if import_result.errors > 0:
print(f"Encountered {import_result.errors} errors")
List Collections
# List available collections
collections = client.list_collections()
for collection in collections.collections:
print(f"{collection.name}: {collection.total_files} files, {collection.total_size_bytes} bytes")
Health Check
# Check server health
health = client.health()
print(f"Server status: {health.status}")
print(f"Server version: {health.version}")
API Reference
Client Configuration
SiftDBClient(
base_url="http://localhost:8080", # Server URL
timeout=30, # Request timeout in seconds
default_collection="/path/to/db" # Default collection path
)
Search Parameters
client.search(
query="search text", # Required: search query
collection="/path/to/db", # Optional: override default collection
path_filter="**/*.py", # Optional: glob pattern for file filtering
regex=False, # Optional: treat query as regex
limit=1000 # Optional: max results
)
Import Parameters
client.import_files(
source_path="/path/to/source", # Required: source directory
collection="/path/to/collection", # Optional: override default collection
include_patterns=["**/*.py"], # Optional: files to include
exclude_patterns=["**/build/**"] # Optional: files to exclude
)
Error Handling
from siftdb import SiftDBClient, SiftDBException
try:
client = SiftDBClient()
results = client.search("my query")
except SiftDBException as e:
print(f"SiftDB Error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
Data Models
SearchResponse
@dataclass
class SearchResponse:
query: str # Original search query
total_matches: int # Total number of matches
results: List[SearchResult] # Search results
duration_ms: float # Search duration
SearchResult
@dataclass
class SearchResult:
file_path: str # File path of the match
line_number: int # Line number where match occurred
line_content: str # Content of the matching line
ImportResponse
@dataclass
class ImportResponse:
message: str # Import completion message
files_ingested: int # Number of files imported
files_skipped: int # Number of files skipped
errors: int # Number of errors encountered
duration_ms: float # Import duration
Requirements
- Python 3.8+
- requests >= 2.25.0
License
MIT
Metadata
Release files for siftdb 0.2.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 | |
|---|---|---|---|---|
| siftdb-0.2.2.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| siftdb-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / siftdb-0.2.2.tar.gz
| Download URL | siftdb-0.2.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a53945ab0dc9c05da93428a75f34c50ff0474ea6b59f14d347b9e09a00771468
|
|
BLAKE2b-256 checksum How to use checksums |
2f3cf9dd55ee617c8a43022678e6cbb684fc67188cad97f39666c0c46d83a8b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / siftdb-0.2.2-py3-none-any.whl
| Download URL | siftdb-0.2.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
054d4b71c51571dee4ab891fc310683b68f4d0ada623d45d478cd793f350c3f8
|
|
BLAKE2b-256 checksum How to use checksums |
546014b6b68818bf774b9e9cd011573950d8a218f0d235dc3277d9f4c3361c8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Security for siftdb 0.2.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.