moss-connector-mongodb
MongoDB source connector for Moss. Self-contained, no separate core package to install.
Install
pip install moss-connector-mongodb
Pulls pymongo as a dependency.
Usage
import asyncio
from moss import DocumentInfo
from moss_connector_mongodb import MongoDBConnector, ingest
async def main():
source = MongoDBConnector(
uri="mongodb://localhost:27017",
database="shop",
collection="articles",
mapper=lambda r: DocumentInfo(
id=str(r["_id"]),
text=r["body"],
metadata={"title": r["title"]},
),
filter={"status": "published"}, # optional
projection={"_id": 1, "title": 1, "body": 1}, # optional
)
result = await ingest(
source,
project_id="your_project_id",
project_key="your_project_key",
index_name="articles",
)
print(f"copied {result.doc_count} rows")
asyncio.run(main())
Use auto_id=True when your mapper does not have a stable primary key and you want Moss to generate UUID document IDs.
MongoDB's _id is a bson.ObjectId. Wrap it with str() in your mapper to render the hex string.
Layout
src/
├── __init__.py # re-exports MongoDBConnector and ingest
├── connector.py # MongoDBConnector class
└── ingest.py # ingest() - keep in sync with the other connector packages
Tests
pip install -e ".[dev]"
pytest tests/test_mongodb.py -v # mocked Moss + mocked Mongo
pytest tests/test_integration_mongodb_moss.py -v -s # live Moss + local Mongo
The live integration test expects a Mongo at mongodb://localhost:27017 - edit MONGODB_URI at the top of the test file to change.
Metadata
Release files for moss-connector-mongodb 0.0.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 |
|---|---|---|---|---|
| moss_connector_mongodb-0.0.1.tar.gz | 6.6 kB | Without provenance | Details for moss_connector_mongodb-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moss_connector_mongodb-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for moss_connector_mongodb-0.0.1-py3-none-any.whl |
Total release size: 10.8 kB
Release files / moss_connector_mongodb-0.0.1.tar.gz
| Download URL | moss_connector_mongodb-0.0.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aeb8d3f7490de819ee4710f5bcea3229752410aebd0828e7317bc847bd525893
|
|
BLAKE2b-256 checksum How to use checksums |
56617ad8c2974885649652e2978dec4d92402de43ef5eed19aab977efefc7c93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / moss_connector_mongodb-0.0.1-py3-none-any.whl
| Download URL | moss_connector_mongodb-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ee68d3cbe410fe2425d80e37350148b8c8ab8b40b69a370ef01f659d895c42b
|
|
BLAKE2b-256 checksum How to use checksums |
23bff7b66a9d5717b12f87990e3f6072fc0925fb33c41742139583c5faeb8008
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for moss-connector-mongodb 0.0.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.