Junior — Middle
What ORM systems have you used in your projects?
sobes.tech AI
Answer from AI
In Python projects, I have used the following ORM systems:
-
SQLAlchemy: A very powerful and flexible ORM supporting various DBMS. It allows writing both declarative models and using Core for lower-level access.
-
Django ORM: Built-in ORM in the Django framework, convenient for quickly creating web applications with a database.
-
Peewee: A lightweight and simple ORM suitable for small projects and prototypes.
Example of using SQLAlchemy:
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
engine = create_engine('sqlite:///example.db')
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()
new_user = User(name='Alice')
session.add(new_user)
session.commit()
The choice of ORM depends on the project requirements, model complexity, and team preferences.