CS475 Project: Object Relational Mapper (ORM)
This project is a simple, stand-alone and lightweight implementation of an Object Relational Mapper (ORM) for Python. The ORM is a library that allows developers to interact with a relational database using Python objects. The ORM will handle the mapping of Python objects to database tables and vice versa.
Installation
You can install the ORM by running the following command:
pip install borm
How to use
The first step to is to design your models (tables). For each model you can inherit from models.Model and define its
fields as class attributes of available fields from the fields module.
from borm import Model
from borm.fields import UUIDField, StringField, IntegerField
class MyModel(Model):
id = UUIDField(primary_key=True)
name = StringField()
rating = IntegerField()
As appears in the example above, you can define the primary key by setting the primary_key attribute to True in
only one field. Then you can start data manipulation by creating instances of your models, etc.
from uuid import uuid4
id_1 = uuid4()
my_model = MyModel.objects.create(id=id_1, name='My Model', rating=5)
print(my_model.id)
print(my_model.name)
print(my_model.rating)
id_2 = uuid4()
my_model_2 = MyModel.objects.create(id=id_2, name='My Model 2', rating=4)
print(my_model_2.id)
print(my_model_2.name)
print(my_model_2.rating)
models = MyModel.objects.all()
for model in models:
print(model.id)
print(model.name)
print(model.rating)
specific_model = MyModel.objects.get(id=id_1)
print(specific_model.id)
models_with_rating_4 = MyModel.objects.filter(rating=4)
for model in models_with_rating_4:
print(model.id)
print(model.name)
print(model.rating)
Furthermore, you may manipulate and update the data in the database by updating the fields of the model instances and
calling the save method to apply the changes to the database.
my_model.rating = 3
my_model.save()
Finally, you can delete a model instance by calling the delete method.
my_model._delete()
Unit Testing
TODO
Metadata
Release files for borm 0.0.1
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 |
|---|---|---|---|---|
| borm-0.0.1.tar.gz | 4.2 kB | Without provenance | Details for borm-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| borm-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for borm-0.0.1-py3-none-any.whl |
Total release size: 10.0 kB
Release files / borm-0.0.1.tar.gz
| Download URL | borm-0.0.1.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34b06246861caa63a7e33446c5052262d374c839668c4fdc3dce01f7636afcb8
|
|
BLAKE2b-256 checksum How to use checksums |
34f7dfb67604e800c7cddc51c1519eb448e21d4ec51053d804074ef66b01045c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Release files / borm-0.0.1-py3-none-any.whl
| Download URL | borm-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61053943a09281a86d38670c9aa6ed98e72f67eff97eb1801e5e3af9e0b014df
|
|
BLAKE2b-256 checksum How to use checksums |
cac338c60f9275e6c6dcd15ec7de2a707470c558709c63f03e1cd97a0dd75f59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.9.19
|
Security for borm 0.0.1
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.