Skip to main content

Model based ORM in RAM

Project description

ramorm [Alpha]

Model based ORM in RAM. Made for performance. Please do not store critical data (yet)

codecov

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

  • [x] PyPI package

  • [ ] Integration with postgresql, redis

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
ramorm-0.0.11-py3-none-any.whl (6.0 kB) Copy SHA256 hash SHA256 Wheel py3
ramorm-0.0.11.tar.gz (4.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page