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.3.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

mongomoron-0.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mongomoron-0.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for mongomoron-0.3.tar.gz
Algorithm Hash digest
SHA256 ae4e7d30bb743bd70be2417b639e974aa2f2240869ae327f78bb13fee49aae21
MD5 59a769dc54d44c051de13e7c3838b66b
BLAKE2b-256 00b2b089462cb73e94a10a4e9a55bd26d4e7b828a05a7c0907c1b17249a618bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mongomoron-0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for mongomoron-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3b4c9fc3cf147e400fb487914927eba88751152cdb5bfc93e9fca66fbdc3134c
MD5 cf85801011352e3b8597553043fca9f0
BLAKE2b-256 cf58c48f434ee76b1675b10269c644221ed6744f0efc27e528dff5bd5e5ed209

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