~/talk

Let's Build an ORM

Talkat PyOhio 2019 · 2019-07-27..07-28· [databases]
name:Greg Back
links:none on file
slides:none on file

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

  1. 0:00Start
  2. 3:02query for all of the records of a particular type
  3. 5:52define our tables
  4. 9:23create these tables in the database
  5. 12:40translate a python class name into a table
  6. 14:20inspect various python objects
  7. 16:36query the database for all of the tables
  8. 19:34put all of the keyword arguments into values in the dictionary
  9. 21:59get the attributes off of the objects
  10. 29:49set the id of the instance that we're saving to the database
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.