Skip to content

alexgurrola/snakelet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5b9b552 · Aug 17, 2021

History

28 Commits
Aug 17, 2021
Feb 21, 2018
Feb 21, 2018
Aug 5, 2019
Aug 8, 2019
Aug 8, 2019
Aug 4, 2019
Aug 5, 2019
Aug 5, 2019
Feb 21, 2018
Feb 21, 2018
Aug 19, 2019
Aug 19, 2019
Mar 17, 2018
Aug 4, 2019
Feb 21, 2018
Aug 5, 2019
Aug 5, 2019

Repository files navigation

snakelet

Codacy Badge https://travis-ci.com/alexgurrola/snakelet.svg?branch=master https://scrutinizer-ci.com/g/alexgurrola/snakelet/badges/quality-score.png?b=master https://scrutinizer-ci.com/g/alexgurrola/snakelet/badges/coverage.png?b=master

Snakelet is a Schema-less ORM-like system built in pure Python to reduce redundancy with Mongo Native Drivers and Object Management. This package contains a very simple implementation and will need to be expanded upon largely to remain relevant.

documents

Registration only requires exposing the object to the Manager.

from snakelet.storage import Document, Manager

class Cat(Document):
    pass

manager = Manager(database='felines')
manager.register(Cat)

managers

Connecting to a database is fairly straightforward.

from snakelet.storage import Manager

manager = Manager(
    database='felines',
    host='localhost',
    port=27017,
    username='admin',
    password='pass'
)

By default, Managers build and fetch collections in snake case, but this can be switched to camel case during instantiation.

from snakelet.storage import Manager

manager = Manager(
    case='camel'
)

Finding, Saving, and Removal are also pretty straightforward.

pye = manager.Cat.find_one({'name': 'pyewacket'})
shoshana = Cat()
shoshana['name'] = 'shoshana'
shoshana['owner'] = 'schrodinger'
manager.save(shoshana)
schrodinger = manager.Cat.find({'owner': 'schrodinger'})
manager.remove(pye)

pagination

This feature set is fairly simple and has normal iterable bindings to ensure simple operation.

for page in manager.Cat.paginate(find={'name': 1}):
    for cat in page:
        print(cat['name'])