A Python SDK for exporting MongoDB schema metadata
Project description
mongodb-schema
A Python SDK for exporting MongoDB schema metadata without copying the actual data.
Installation
pip install mongodb-schema
Dependencies
Requirements.txt Setup
Update your requirements.txt to include:
pymongo>=4.10.1
Note: Do not include the standalone bson package as it conflicts with pymongo.
To regenerate requirements:
pip freeze > requirements.txt
To reinstall dependencies:
pip install --force-reinstall -r requirements.txt
BSON Troubleshooting
If you encounter BSON-related errors, run:
pip uninstall bson pymongo
pip install pymongo
Usage
Command Line Interface
mongodb-schema --uri mongodb://user:password@database.host1.com:27017/admin --databases test2,testIgnore --output schema.json
Python API
from mongodb-schema.exporter import MongoSchemaExporter
# Initialize the exporter with MongoDB connection details
exporter = MongoSchemaExporter(uri="mongodb://localhost:27017", database="test_db")
# Export the schema metadata for the specified database
result = exporter.export_schema(sample_size=10)
# Print the result
print(result)
Arguments
--uri: MongoDB connection string--databases: Comma-separated list of databases to export--output: Output file path for schema (e.g.,schema.json)
Example Output
Schema exported to schema.json
Permissions
Ensure your user has appropriate read permissions for the specified databases.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mongodb_schema-0.1.1.tar.gz.
File metadata
- Download URL: mongodb_schema-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05e1783e206bbfc3da6e82a71625bd8ce3bd782b35c53f6f177ba95c0f2d09e4
|
|
| MD5 |
9d596085c5d46953279a5161fbddbc6a
|
|
| BLAKE2b-256 |
a3c7df39f579ae7fbf47fe7cae0d0c789ce71f7b971b11e975389f082f34b02b
|
File details
Details for the file mongodb_schema-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mongodb_schema-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
562711d803297978264f4aab50e9bc0e69fef8ee453c48989bebf9a0fc46edef
|
|
| MD5 |
8cb98c91c5249f2335ae9ca7e3ff9430
|
|
| BLAKE2b-256 |
e436c486ac9ae43b6dce9023ca626c00d5142fcaa6def706398ae59996bf5d40
|