### Install via PyPi (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Install the latest stable version of the pymongo-schema library using the pip package manager from PyPi. ```Shell pip install --upgrade pymongo-schema ``` -------------------------------- ### Install via GitHub (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Install the latest version of the pymongo-schema library directly from the GitHub repository using the pip package manager. ```Shell pip install --upgrade git+https://github.com/pajachiet/pymongo-schema ``` -------------------------------- ### Populate MongoDB Collection (MongoDB Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Insert sample documents into a MongoDB collection named 'users' using the mongo shell to provide data for schema analysis examples. ```MongoDB Shell db.users.insert({name: "Tom", bio: "A nice guy.", pets: ["monkey", "fish"], someWeirdLegacyKey: "I like Ike!"}) db.users.insert({name: "Dick", bio: "I swordfight.", birthday: new Date("1974/03/14")}) db.users.insert({name: "Harry", pets: "egret", birthday: new Date("1984/03/14"), location:{country:"France", city: "Lyon"}}) db.users.insert({name: "Geneviève", bio: "Ça va?", location:{country:"France", city: "Nantes"}}) db.users.insert({name: "MadJacques", location:{country:"France", city: "Paris"}}) ``` -------------------------------- ### Display Main CLI Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the main help message for the pymongo-schema command-line interface, listing the available top-level commands. ```Shell python -m pymongo_schema -h usage: [-h] [--quiet] {extract,transform,tosql,compare} ... commands: {extract,transform,tosql,compare} extract Extract schema from a MongoDB instance transform Transform a json schema to another format, potentially filtering or changing columns outputs tosql Create a mapping from mongo schema to relational schema (json input and output) compare Compare two schemas optional arguments: -h, --help show this help message and exit --quiet Remove logging on standard output ``` -------------------------------- ### Display ToSQL Command Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the help message and available options specifically for the 'tosql' command within the pymongo-schema CLI. ```Shell python -m pymongo_schema tosql -h usage: [-h] [-f [FORMATS [FORMATS ...]]] [--columns COLUMNS [COLUMNS ...]] [--without-counts] [-o OUTPUT] [input] ``` -------------------------------- ### Display Compare Command Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the help message and available options specifically for the 'compare' command within the pymongo-schema CLI. ```Shell python -m pymongo_schema compare -h usage: [-h] [-f [FORMATS [FORMATS ...]]] [-o OUTPUT] [input] [--columns COLUMNS [COLUMNS ...]] [--without-counts] [--detailed_diff] prev_schema [new_schema] ``` -------------------------------- ### Display Transform Command Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the help message and available options specifically for the 'transform' command within the pymongo-schema CLI. ```Shell python -m pymongo_schema transform -h usage: [-h] [-f [FORMATS [FORMATS ...]]] [-o OUTPUT] [--category CATEGORY] [-n FILTER] [--columns COLUMNS [COLUMNS ...]] [--without-counts] [input] ``` -------------------------------- ### Display Extract Command Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the help message and available options specifically for the 'extract' command within the pymongo-schema CLI. ```Shell python -m pymongo_schema extract -h usage: [-h] [-f [FORMATS [FORMATS ...]]] [-o OUTPUT] [--port PORT] [--host HOST] [-d [DATABASES [DATABASES ...]]] [-c [COLLECTIONS [COLLECTIONS ...]]] [--columns COLUMNS [COLUMNS ...]] [--size SIZE] [--without-counts] ``` -------------------------------- ### Display Specific Command Help (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Show the help message for a specific pymongo-schema command by appending '-h' after the command name. ```Shell pymongo-schema -h ``` -------------------------------- ### Map MongoDB Schema to SQL (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md This command demonstrates piping the JSON schema output from `pymongo-schema extract` to the `pymongo-schema tosql` module. This process extracts the MongoDB schema from the `test` database and then transforms it into a relational mapping representation, suitable for SQL database design. ```Shell $ python -m pymongo_schema extract --database test | python -m pymongo_schema tosql ``` -------------------------------- ### Import Python Modules (Python) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md Import core functions from the pymongo-schema library to use its functionalities programmatically within Python code. ```Python from pymongo_schema.compare import compare_schemas_bases from pymongo_schema.export import transform_data_to_file from pymongo_schema.extract import extract_pymongo_client_schema from pymongo_schema.filter import filter_mongo_schema_namespaces from pymongo_schema.tosql import mongo_schema_to_mapping ``` -------------------------------- ### Extract MongoDB Schema to Markdown (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md This command extracts the schema from the `test` MongoDB database using `pymongo-schema`, similar to the JSON extraction. However, it specifies the `--format md` option to output the schema in a human-readable Markdown table format. ```Shell $ python -m pymongo_schema extract --database test --format md ``` -------------------------------- ### Extract MongoDB Schema to JSON (Shell) Source: https://github.com/pajachiet/pymongo-schema/blob/master/README.md This command uses the `pymongo-schema` module to connect to a MongoDB database named `test` and extract its schema. The output is printed to standard output in JSON format, detailing collection structure, field types, counts, and percentages. ```Shell $ python -m pymongo_schema extract --database test ``` -------------------------------- ### Define String Type Schema - JSON Source: https://github.com/pajachiet/pymongo-schema/blob/master/tests/resources/functional/expected/detailed_diff.md Defines a simple schema object specifying that the field's type is a string. ```JSON {"type": "string"} ``` -------------------------------- ### Define String Schema with Stats - JSON Source: https://github.com/pajachiet/pymongo-schema/blob/master/tests/resources/functional/expected/detailed_diff.md Defines a schema object for a string field, including statistical information like count, proportion within an object, and type counts. ```JSON {"count": 93463, "prop_in_object": 3.6856, "type": "string", "types_count": {"string": 93463}} ``` -------------------------------- ### Define Array Type Schema - JSON Source: https://github.com/pajachiet/pymongo-schema/blob/master/tests/resources/functional/expected/detailed_diff.md Defines a simple schema object specifying that the field's type is an array. ```JSON {"type": "ARRAY"} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.