Plume is a single file, minimalist ORM for sqlite3 database. It is not suited for production, and might never be. Nevertheless, it aims to be an eductional support to python newcomer by keeping a codebase as clean as possible. Moreover, it is my own way to improve my understanding on ORMs.
Plume only dependency is the Python Standard Library.
/!\ Some major API changes are about to come, the README is not up to date for now /!\
- Models to interact with tables in database.
- QueryManager to enable SQL queries with a functional style.
A class-based interface to interact with a table in the database.
class User(Model):
username = TextField(max_length=30, unique=True)
city = TextField(max_length=100, required=False)
age = IntegerField()
User.objects.create(city='Nantes', age=23)
or
user = User(city='Nantes', age=23)
user.save()
users = User.bulk_create([user1, user2, user3])
users = User.objects.filter(User.city == 'Nantes')
users = result = User.objects.filter(User.age > 18)
users = User.objects.filter(User.city == 'Nantes' | User.city == 'Lyon')
users = User.objects.filter(User.city == 'Nantes' & User.age > 18)
users = User.objects.all()
or
users = User.objects.select()
or
users = User.objects.select('*')
users = User.objects.select(User.name, User.age)
users = User.objects.select('name', 'age')
users = User.objects.order_by(User.age, User.name)
users = User.objects.order_by('age', 'name')