A declarative ORM from scratch, compatible with SQLite
Use the package manager pip to install flamel.
pip install flamel-orm
from flamel.base import Base
from flamel.column import Column, Integer, String
class Worker(Base):
id = Column("id", Integer, primary_key=True, autoincrement=True)
name = Column("name", String, nullable=False, unique=True)
email = Column("mail", String, nullable=False, unique=True)
Base.set_engine("company.db")
Base.create_tables()
worker = Worker(name='John Doe', email='[email protected]')
worker2 = Worker(name='Jane Smith', email='[email protected]')
worker3 = Worker(name='Mike Johnson', email='[email protected]')
Base.insert(worker)
Base.insert(worker2)
Base.insert(worker3)
query = Worker.query().select().filter(name="John Doe")
print(query)
result = query.execute()
print(result)
Base.engine_close()
- MVP of the ORM
- Implement a way to insert data
- Implement group_by
- Implement having
This project is thanks to other projects and people:
Licensed under MIT.