Nopea
(Version 0.0.16)
Purpose
Provides an ORM for MySQL, PostgreSQL and SQLite.
Usage
To use the power of Nopea you need to set up an adaptor and let your classed inherit from nopea.DbObject.
Setting up Adaptor and Connection
from nopea.dbobject import DbObject
from nopea.adaptors.sqlite import SQLiteAdaptor
DbObject = DbObject
DbObject.adaptor = SQLiteAdaptor('nopea.db')
Creating a subclass
class User(DbObject):
name = nopea.CharField(max_length=25)
password = nopea.CharField(max_length=50)
describtion = nopea.TextField()
registered = nopea.DateField()
logins = nopea.IntegerField()
active = nopea.BooleanField(default=True)
Users automatically get an additional id field which is an instance of nopea.fields.PkField
.
Instance methods:
instance.save()
instance.delete()
Class methods
User.create_table()
Manager operations:
The class provides an interface to create objects: The objects manager.
User.objects.all()
User.objects.get(key=value)
User.objects.filter(key=value)
User.objects.filter(logins__gte=10, logins__lte=50)
User.objects.exclude(key=value)
User.objects.create()
User.objects.create(name='Christian')
User.objects.order_by('name')
User.objects.count()
DbObject class methods
DbObject.raw(query, args)
DbObject.raw(
"INSERT INTO user (name, description)
VALUES (?, ?)", 'Christian', 'Nopea developer.'
)
License
Nopea is available under the terms of the GPLv3.
Disclaimer
This software comes without any warranty. You use it on your own risk. It may contain bugs, viruses or harm your software and hardware in another way. The developer is not responsible for any consequences which may occur caused by using the software.