Skip to main content

Vanilla wrapper around pymongo

Project description

Motivation

This lib is intended to be some surrogate of SqlAlchemy for no-sql database, particularly for mongo.

I checked up MongoAlchemy (seems to be dead), MongoEngine and some smaller libs but seems no one of them fits.

Basically I need builders for query filters and aggregation pipelines. However schema is not needed, so any table can have any fields and any operation can be applied to any field.

For example, instead of

cursor = db.my_table.aggregate([{
    '$match': {
        '$expr': {
            '$and': [{
                '$eq': ['$col', 'col value']
            }, {
                '$in': [
                    '$details.key',
                    ['key 1', 'key 2', 'key 3']
                ]
            }]
        }
    },
}, ...])

I wish to write

p = aggregate(my_table)
    .match(my_table.col == 'col value' and \
        my_table.details.key in ['key 1', 'key 2', 'key 3'])
    ....
cursor = conn.execute(p)

Advantages:

  • more clear and readable code;
  • can use IDE's autocomplete;
  • ability to implement shortcuts for commonly used operations.

Naming

Because names MongoAlchemy and NoSqlAlchemy were not vacant, I chose mongomoron because it was first what came to mind, and because of that lib is for morons like me for whom dealing with mongo's json is too difficult.

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

mongomoron-0.1.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

mongomoron-0.1.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file mongomoron-0.1.1.tar.gz.

File metadata

  • Download URL: mongomoron-0.1.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5

File hashes

Hashes for mongomoron-0.1.1.tar.gz
Algorithm Hash digest
SHA256 718b55d62fadc8e0c1a011deb7e6c8fcfa9e2deab25f83f53d1f63bdd560153b
MD5 4bb3f97b9967484e83058367f058c40b
BLAKE2b-256 d0d0e8f99b8c15cb851aa707fadc2ca53382d6520afda22c44b3148cac3345a3

See more details on using hashes here.

File details

Details for the file mongomoron-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mongomoron-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for mongomoron-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 057cf5b240504cb88ca2ca49a7439763d92d08277d0eb5f2fb8637274142c368
MD5 ce5414b302631e21ee84047b9c109116
BLAKE2b-256 588650e11a8f37a574cd0be3f7fce1e0672db29a348cfb1b324e1802990139a1

See more details on using hashes here.

Supported by

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