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.0.tar.gz (3.8 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.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

Hashes for mongodb_schema-0.1.0.tar.gz
Algorithm Hash digest
SHA256 adcd5af6000b3bdf687130316c2d60d6390b0382c6aed612738e34f316142d4b
MD5 5d2ce973ac20214c97a440b024696e5f
BLAKE2b-256 e3c2f6484b778ca40c09017489da9fd389af6a527fb594916194e9137f43a65a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mongodb_schema-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6690649b7a7eaa6ed69645124311cf7611758844f04271e2a80ebc6bcc29d346
MD5 37fadfe056d5cc961f1589e7df2d43aa
BLAKE2b-256 2a2458d6cc25aeb7fabc1ab054b292567dfdbdf9f41997f3a32c076e3ae10a15

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