Let's Build an ORM
summary
Live-coding builds a small ORM for SQLite only that defines tables from Python classes, maps Python types to SQLite types, creates tables, inserts rows (using parameterized queries to avoid SQL injection), reads all rows and single rows by ID, and sets instance IDs from cursor.lastrowid. Implementation uses inspect, classmethods, and __getattr__ to expose columns as attributes; the demo runs test-driven examples and shows 8 tests passing with code published on GitHub and slides linked from the conference page.
AI-written summary · about
chapters (10)
- 0:00Start
- 3:02query for all of the records of a particular type
- 5:52define our tables
- 9:23create these tables in the database
- 12:40translate a python class name into a table
- 14:20inspect various python objects
- 16:36query the database for all of the tables
- 19:34put all of the keyword arguments into values in the dictionary
- 21:59get the attributes off of the objects
- 29:49set the id of the instance that we're saving to the database
related talks
32mNo More Raw SQL: SQLAlchemy & ORMs
37mNo More Raw SQL with SQLAlchemy and ORMs
29mDatabase Sorcery 101 Ditch the Ancient SQL Scrolls for SQLModel
01h 28mSQLAlchemy and You - Making SQL the Best Thing Since Sliced Bread
01h 03mPersisting C++ Classes in Relational Databases with ODB
30mThe magic of SQLAlchemy
20mYou don't need an ORM
32mORM: The Sequel
