# Schema extractor for MongoDB
Mongo-inspector is a Python library that analyses the data of a MongoDB
database to extract its "schema" (I know...).
## Installation
$ pip install mongo-inspector
## Usage
import mongo_inspector
schema = mongo_inspector.extract_schema(
db_name='mydb',
host='myhost', # optional: default 'localhost'
port=xxxx # optional: default 27017
)
The returned schema looks like that:
{
u'SomeCollection': [
Attribute(name=u'id', types=[u'String']),
Attribute(name=u'someattribute', types=[u'String'])
],
u'AnotherCollection': [
Attribute(name=u'_id', types=[u'ObjectId']),
Attribute(name=u'someattr', types=[u'Object']),
Attribute(name=u'someattr.nested', types=[u'Number']),
Attribute(name=u'somelist', types=[u'Array']),
Attribute(name=u'somelist.__item__', types=[u'Object']),
Attribute(name=u'somelist.__item__.nested',
types=[u'String', u'Number'])
]
}
`Attribute(name, types)` is just a `nametuple`. Each attribute can have
several types.
## Future
* It might be usefull to return a tree instead of 'point-separated'
nested keys.
Mongo-inspector is a Python library that analyses the data of a MongoDB
database to extract its "schema" (I know...).
## Installation
$ pip install mongo-inspector
## Usage
import mongo_inspector
schema = mongo_inspector.extract_schema(
db_name='mydb',
host='myhost', # optional: default 'localhost'
port=xxxx # optional: default 27017
)
The returned schema looks like that:
{
u'SomeCollection': [
Attribute(name=u'id', types=[u'String']),
Attribute(name=u'someattribute', types=[u'String'])
],
u'AnotherCollection': [
Attribute(name=u'_id', types=[u'ObjectId']),
Attribute(name=u'someattr', types=[u'Object']),
Attribute(name=u'someattr.nested', types=[u'Number']),
Attribute(name=u'somelist', types=[u'Array']),
Attribute(name=u'somelist.__item__', types=[u'Object']),
Attribute(name=u'somelist.__item__.nested',
types=[u'String', u'Number'])
]
}
`Attribute(name, types)` is just a `nametuple`. Each attribute can have
several types.
## Future
* It might be usefull to return a tree instead of 'point-separated'
nested keys.
Release files for mongo-inspector 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distributions (sdists)
| File | Size | Uploaded | |
|---|---|---|---|
| mongo-inspector-0.2.zip | 5.8 kB | Details | |
| mongo-inspector-0.2.tar.gz | 3.5 kB | Details |
Release files / mongo-inspector-0.2.zip
| Download URL | mongo-inspector-0.2.zip |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f3dbdddfe9e78840607f6b1d6a3407f24c4f6014f8ad895a7df3f8209c06f4c
|
|
BLAKE2b-256 checksum How to use checksums |
a28b24fabfe36580c0f8ade495ada9e714c9802d61624f6ee11f812994870a78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / mongo-inspector-0.2.tar.gz
| Download URL | mongo-inspector-0.2.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9021874dd3a34faf3be7e227822fd55bf7552f4f78b1f5035fa542416eafa742
|
|
BLAKE2b-256 checksum How to use checksums |
9700b8ee442402e7df8b631c4358aec18f7dcfba46741e0b792942e071b83719
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |