• New Schema Migrations Module for Peewee ORM

    April 20, 2014 19:34 / 0 comments

    I'm please to announce that peewee now has more robust support for schema migrations. Basic migration support for Postgres has existed for some time, but peewee now supports SQLite and MySQL as well. In addition, there were a couple of issues with the original migrations API. Schema migrations have been one of the most-requested features, so I'm hopeful that with the addition of this feature, peewee users will have one more reason to enjoy using the library!

    Check out the rest of the post for more details.


  • Python's yield from

    April 13, 2014 12:13 / 0 comments

    The yield from syntax, introduced in PEP 380, is getting a lot of attention lately due to its important role in the new asyncio package. I did not immediately understand what this syntax provides, but I have a handy way of thinking about it which I thought I'd share on my blog.

    Imagine you have an arbitrarily nested list structure like so:

    lists = [
        1, 2, 3,
        [4, 5, [6, 7], 8],
        [[[9, 10], 11]],

    You can flatten this data-structure by writing a recursive generator thanks to the new yield from syntax:

    def flatten(items):
        for item in items:
            if isinstance(item, (list, tuple)):
                yield from flatten(item)
                yield item

    The output would then be:

    >>> [item for item in flatten(lists)]
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

    To achieve this using Python 2.x, which does not have yield from, you would instead write the recursive call like this:

    if isinstance(item, (list, tuple)):
        for subitem in flatten(item):
            yield subitem


  • In Honor of Spring...

    March 17, 2014 11:18 / 0 comments

    Two new themes.


  • Lawrence, KS

    February 26, 2014 11:18 / 5 comments

    I am proud to live in Lawrence, KS, a college town of about 100,000 which has been my home for the majority of my life. Perhaps the most striking feature about my home is the amazing sky here -- nowhere else I've lived comes close:

    Being in the tech industry, I'm often asked if I have plans to move away to a place with more jobs. I always answer simply and somewhat apologetically that I intend to stay in Kansas. Answering that way is so much less embarassing than explaining why I love Kansas. My home is very much a part of me, though, and I'd like to write just once about why I am so happy to live here.


  • How do you use peewee?

    February 22, 2014 13:11 / 5 comments

    When I first wrote peewee I set out to accomplish a simple task: make it easy to execute queries in my Flask apps. I was a bit familiar with SQLAlchemy, but wanted something lightweight and thought it would be a quick project. While the first version only took a couple days to write, over the past two or three years peewee has been my favorite project to work on. I've been very surprised to see that it's user base has grown, and would like to ask anyone who is using peewee:

    How do you use peewee?

    I'd like to add a "testimonials" section to the documentation that describes the interesting projects people have written using peewee. If you don't mind sharing, I'd love to hear about your project.


  • More posts...