Tagged with


SQLAlchemy Cascade Delete: Clarity through Examples

Since there is overlapping "cascade delete" functionality supported by SQLAlchemy -- with the ORM handling some deletes and the database itself handling others -- it can be hard to know the right way to set it up. Here are some examples to help clarify how it all works.

Starting Example

Here we …

My Best Side Project

After a few years working on it, I can say that the "magic mirror" I built with my son has been the best for-fun side project I've ever done. When I was describing the idea, my wife was hesitant about letting me hang it on the wall -- mostly due to …

I'm concerned about using Python

xkcd Python


Python is slow

  • Is the CPU the bounding factor for the project's performance?
  • How much time has been spent trying to optimize performance?
  • Which is currently more important, raw execution speed or time to create features?
  • Is Python fast enough for the project?
  • It is an often used strategy …

Granular Profiling in PyCharm

PyCharm added profiler integration in version 4.5, which I thought was pretty cool. Used as documented, though, it hasn't been terribly useful. Here's a way to improve on that.

In my case, I was interested in profiling a web service -- specifically requests to a particular resource. I started up …

Run/Debug as root in PyCharm

I'm working on a Python project that needs to run as root in order to work properly. Previously I've just run the whole PyCharm IDE as root, but this has some down-sides, and I think I have a better approach now.

The biggest hassle with running the IDE as root …

Your right margin is telling you something

The recommendation to keep lines widths less than 80 characters is a surprising part of the Python style guide (PEP 8). Really, 79 characters? Is it still the 1980's in Python-land? Maybe it's time to upgrade that monochrome CRT and get some screen real-estate.

Acting a bit on faith, and …

SQLAlchemy with Python 64-bit on Windows

While hooking up SQLAlchemy for a web project, I kept running into attribute errors for 'session_registry'. I figured I was doing something wrong, so I thought I'd just walk through the tutorial as a sanity check.

I was, apparently, insane.

>>> u = session.query(User).filter_by(name='ed …

Python Packaging (2013 Edition)

About a year ago, I set out to get a solid working understanding of Python packaging, resulting in a lengthy blog post of what I learned. There have been some significant course changes over that year such that my original post is wrong in several regards.

Here's a summary of …

Getting pip into your Python 3 venv

Python 3.3 includes a built-in equivalent to the popular virtualenv tool for creating isolated Python environments. One difference with the built-in venv is that it doesn't automatically install pip as virtualenv does. While I can understand the decision (given Python's volatile packaging situation), it isn't very convenient.

Here's a …

Python Packaging Demystified

IMPORTANT: Some of the information in this post is now obsolete. Please see here.

Randomly take a couple of words from the following list, put them together, and there's a decent chance you'll come up with something real involving Python packaging.

  • setup
  • install
  • dist
  • distribute
  • tools
  • utils
  • easy
  • py

The …