Hacker News new | past | comments | ask | show | jobs | submit login

> I don’t understand people’s love of ORMs instead of simply learning SQL

> Want to make a composite primary key? I have no idea how you would do it with most ORMs,

Since you mentioned SQLAlchemy

    class MyTable(Base):
      col1 = sa.Column(sa.Integer, primary_key=True)
      col2 = sa.Column(sa.Integer, primary_key=True)

ORMs aren't an alternative to learning SQL.

* Type safety on all SQL operations.

* All the benefits of a query builder.

* Reverse relationships that read better in code `parent.children`.

* External file management that is generic, works on all your tables the same way, and supports multiple simultaneous back-ends making migrations easy.

* Object de/serialization and transformations letting you use native types like datetime.

* Typed/parsed JSON columns, I use Pydantic for this.

* Handling single/multi table inheritance for you and giving you type safety.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: