If the DB only needs to stick around for the life of this script, which I assume is true based on the ":memory:" comment below, a `tempfile.NamedTemporaryFile` might simplify things here.