Zerorm
Zerorm is a simple wrapper for three amazing packages. This repository is the place where TinyDB, Schematics and Lifter together look like Django ORM.
It’s still work in progress and not everything looks like Django ORM, but it will.
Installation
pip install zerorm
Usage
First create a file with models and database instance attached to every model:
from zerorm import db, models
database = db('db.json')
class Message(models.Model):
author = models.StringType(required=True)
author_email = models.EmailType()
text = models.StringType()
views = models.IntType(min_value=0)
class Meta:
database = database
Now create some objects:
>>> from models import Message
>>>
>>> bob_message = Message(author='Bob',
... author_email='bob@example.com',
... text='Hello, everyone!')
>>> bob_message
<Message: Message object>
>>> bob_message.save() # Save object
1
>>>
>>> bob_message.views = 3
>>> bob_message.save() # Update object
>>>
>>> alice_message = Message.objects.create(author='Alice',
... text='Hi, Bob!',
... views=0)
>>> alice_message
<Message: Message object>
And try to retrieve them via objects
>>> Message.objects.all()
<QuerySet, len() = 2>
>>> list(Message.objects.all())
[<Message: Message object>, <Message: Message object>]
>>>
>>> second_message = Message.objects.get(eid=2)
>>> second_message.author
'Alice'
>>>
>>> Message.objects.filter(views__gte=3) # Only Bob's message has 3 views
<QuerySet, len() = 1>
>>> list(Message.objects.filter(views__gte=3))
[<Message: Message object>]
You can also redefine model’s __str__ method for better repr just like in Django.
class Message(models.Model):
...
def __str__(self):
return 'by {}'.format(self.author)
>>> list(Message.objects.all())
[<Message: by Bob>, <Message: by Alice>]
License
MIT. See LICENSE for details.
Metadata
Release files for zerorm 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zerorm-0.2.0.tar.gz | 3.4 kB | Without provenance | Details for zerorm-0.2.0.tar.gz |
Release files / zerorm-0.2.0.tar.gz
| Download URL | zerorm-0.2.0.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52c7d71abe913fbe854f3d129ef5734320202b23a3eccbe82c80e6d2a7f25afe
|
|
BLAKE2b-256 checksum How to use checksums |
0ab7c31cec17ed84772c4a08c2e8b601117e1089e2c1446f80e65ea2b256d4d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for zerorm 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.