Code + Product

SQLAlchemy commit(), flush(), expire(), refresh(), merge() - what's the difference?

Nov 2nd, 2017 in Python

I've always struggled to remember between these very similar methods in the SQLALchemy ORM - so I took some time out to research these and write it down.

Prioritized Code Review Checklist - what to look for first, second, and last

Sep 21st, 2017 in ProductPython

A few notes on the code review process, and the steps I go through when reviewing.

Many to many relationships in SQLAlchemy models (Flask)

Jul 28th, 2017 in Python

Building model definitions for many-to-many relationships via a secondary table.

Bash script to relink alembic migrations

Jun 12th, 2017 in PythonTools

Sick of `alembic merge heads` slowing down your builds? Here's a short bash script I wrote to rename your migration files and update its down revision.

Using model callbacks in SQLAlchemy to generate slugs

Feb 7th, 2017 in Python

Dive into SQLAlchemy's little known `event.listen` method to automatically generate slugs when saving a model instance.

Overriding default Jinja dictionary attributes in Python view templates

Jan 29th, 2017 in Python

How to use the `do` Jinja extension to modify an existing dictionary in your view template.

Custom Jinja template filters in Flask

Oct 30th, 2016 in Python

A short snippet for creating a template filter, to present datetime objects in Jinja templates.

JSON field type in SQLAlchemy (Flask / Python)

Sep 8th, 2016 in Python

Want to store JSON-serialized data in your database? But sick of calling `json.loads()` and `json.dumps()` when dealing with this data in your Flask app? Read on!

Resolving alembic merge branch conflicts

May 23rd, 2016 in Python

How to fix alembic's "Multiple head revisions are present for given argument 'head'" error.

Using Python's Watchdog to monitor changes to a directory

Feb 22nd, 2016 in PythonServers and Scaling

A small Python script to take action whenever a new file is uploaded to a directory or its contents change.