Okay, get it. Obviously my app's workflow isn't the only one in world ;-)
That would be enough then:

    if url is None:
        url = os.environ.get('DATABASE_URL')