Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mongodb_schema-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mongodb_schema-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file mongodb_schema-0.1.2.tar.gz.

File metadata

  • Download URL: mongodb_schema-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.2

File hashes

Hashes for mongodb_schema-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c8f8d84ef27606f9b5b37a010d6d692d0410ee017e2002bcb414910fa5d29406
MD5 58828921ae72a11ee88853037d92bcd4
BLAKE2b-256 97ccfe2b4d6935510b9a8f709dc16a096366e64b02da2028cbcf20d4e14d7df7

See more details on using hashes here.

File details

Details for the file mongodb_schema-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mongodb_schema-0.1.2-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

Hashes for mongodb_schema-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32f033c122886e2cd01766daa183a47ef17de4ab419eaad01eb691d39aa9ef65
MD5 9d47d5e555332f09f02ee550b4e3a0dc
BLAKE2b-256 3dbcabeaf7b2008a0ad83fa885c62b8f05c7ebfde26a587215269a2b39806fa5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page