Skip to main content

A small and lightweight ORM

Project description

RACCY-ORM

OVERVIEW

Raccy-ORM is a small lightweight ORM, inspired by Django-ORM.

REQUIREMENTS

  • Python 3.7+
  • Works on Linux, Windows, and Mac

INSTALL

pip install raccy-orm

EXAMPLE

from datetime import datetime as dt
import ro as model

config = model.Config()
config.DATABASE = model.SQLiteDatabase(':memory:')


class Author(model.Model):
    author_id = model.PrimaryKeyField()
    name = model.CharField(max_length=75)
    age = model.IntegerField()
    lucky_number = model.IntegerField(default=90)
    salary = model.FloatField(default=50000)
    date = model.DateField()
    datetime = model.DateTimeField()
    adult = model.BooleanField(default=False)


class Post(model.Model):
    author_id = model.ForeignKeyField(Author, 'author_id')
    post = model.TextField(null=False)


Author.objects.bulk_insert(
    dict(name='Kwame', age=45, date=dt.now().date(), datetime=dt.now(), lucky_number=99, salary=6400),
    dict(name='Yaw', age=32, date=dt.now().date(), datetime=dt.now(), lucky_number=56, salary=6400),
    dict(name='Fiifi', age=23, date=dt.now().date(), datetime=dt.now(), lucky_number=34),
    dict(name='Navas', age=21, date=dt.now().date(), datetime=dt.now()),
    dict(name='Jesus', age=34, date=dt.now().date(), datetime=dt.now(), salary=6400, adult=True)
)
Post.objects.insert(post="This is Kojo's post", author_id=1)
Post.objects.insert(post="This is Kwabena's post", author_id=2)
Post.objects.insert(post="This is Baffour's post", author_id=3)
Post.objects.insert(post="This is Derrick's post", author_id=1)


for d in Author.objects.all():
    print(d.pk, d.name)
1 Kwame
2 Yaw
3 Fiifi
4 Navas
5 Jesus

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

raccy_orm-0.0.1-py3-none-any.whl (23.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page