Model based ORM in RAM
Project description
ramorm [Alpha]
Model based ORM in RAM. Made for performance. Please do not store critical data (yet)
Installation
pip install ramorm
Usage
from ramorm import orm, model
db = orm.Orm('my_test_database')
class Vehicle(model.Model):
name = model.TextField()
wheels = model.IntegerField(default=4)
max_speed = model.IntegerField(default=100)
sports_car = Vehicle(name='Aventador', max_speed=230)
print(sports_car.name,sports_car.wheels, sports_car.max_speed)
>> 'Aventador' 4 230
bicycle = Vehicle(name='Bicycle', wheels=2, max_speed=50)
print(bicycle.wheels, bicycle.max_speed)
>> 'Bicycle' 2 50
Add your model based objects to database using push
function, you can pass one or multiple objects at once
db.push(sports_car, bicycle)
Retrieving single objects from database is possible using get
function
print(db.get(Vehicle, wheels=4).name)
>> 'Aventador'
print(db.get(Vehicle, name='Bicycle').max_speed
>> 50
For filtering numerical parameters you can use __gt
(greater), __gte
(greater or equal), __lt
(lower), __lte
(lower or equal)
print(db.get(Vehicle, max_speed__gt=70).name)
>> 'Aventador'
For retrieving multiple objects at once use filter
for vehicle in db.filter(Vehicle, max_speed__gte=10):
print(vehicle.name, vehicle.wheels, vehicle.max_speed)
>> 'Aventador' 4 230
>> 'Bicycle' 2 50
For deleting objects from db use delete
function. Returns True
if changes were made to database
db.delete(Vehicle, name='Bicycle')
>> True
db.delete(Vehicle, name='Starship')
>> False
If you want completely delete all data in your database use drop
.Returns array of objects in db (empty)
db.drop()
>> []
Coming soon
-
Delete objects using
.delete()
-
Order by
-
Backup to file
-
PyPI package
-
Integration with postgresql, redis
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ramorm-0.0.11.tar.gz
.
File metadata
- Download URL: ramorm-0.0.11.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd530664685d51d4bd9ccf2479f2b74c083caf22b6350539ca02fbac65965cd5 |
|
MD5 | ebc2b2be0a61080dfbb1913db4f30577 |
|
BLAKE2b-256 | 254a99f6fdf499754dbf10250ea3db468f0b7451cfa88016b7c3ee9a827d4abf |
File details
Details for the file ramorm-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: ramorm-0.0.11-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e42eeb2b4b11f4563ad0a244cf0578376fb219f1acb5cbbc5906e9e1b4405a90 |
|
MD5 | d32921bf5c64308b79f2ad9c52a09552 |
|
BLAKE2b-256 | d6c5d89edd002a9ab541dd30209cd437b15143eccf104be57a254f2fece23897 |