Introducing django-postgres-stats
While working on a dashboard project that used Django, I found myself
reaching for functions in PostgreSQL to generate time series data and
calculate percentiles. In Django 1.8,
Func() expressions were added to let users access
database-specific functions more easily. Django subclasses Func to
give you common database functions, so I did the same to expose
some PostgreSQL date/time functions and a percentile function from
the PostgreSQL aggregate functions.
Since we're likely to need these same functions in future projects and I didn't have much practice building Python packages, I wrapped the functions up and open-sourced them. You can read the docs and check out the source code.
One thing I enjoyed about packaging up the code is using pbr to
build the package on the recommendation of
The Hacker's Guide to Python. I found it hard to find what I
needed in the documentation, but it was nice to use besides
that. Using git tags and requirements.txt -- two things I was
already using -- to version the package and set the requirements was
great.
