Tailslide
Median and percentile for Django and MongoEngine
Supports:
- PostgreSQL
- SQLite
- MariaDB
- MySQL (with an extension)
- SQL Server
- MongoDB
:fire: Uses native functions when possible for blazing performance
Installation
Run:
pip install tailslide
For MySQL, also follow these instructions.
Getting Started
Django
Median
from tailslide import Median
Item.objects.aggregate(Median('price'))
Percentile
from tailslide import Percentile
Request.objects.aggregate(Percentile('response_time', .95))
Works with grouping, too, with PostgreSQL, MySQL, and SQLite
Order.objects.values('store').annotate(total=Median('total')).order_by('store')
MongoEngine
Add a custom QuerySet to the models where you want to use it.
from tailslide.mongoengine import TailslideQuerySet
class Item(Document):
meta = {'queryset_class': TailslideQuerySet}
Median
Item.objects.median('price')
Percentile
Item.objects.percentile('price', .95)
Additional Instructions
MySQL
MySQL requires the PERCENTILE_CONT function from udf_infusion. To install it, do:
git clone https://github.com/infusion/udf_infusion.git
cd udf_infusion
./configure --enable-functions="percentile_cont"
make
sudo make install
mysql <options> < load.sql
History
View the changelog
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/tailslide.git
cd tailslide
pip install -r requirements.txt
To run the tests:
# Postgres
createdb tailslide_test
ADAPTER=postgresql pytest tests/django
# SQLite
ADAPTER=sqlite pytest tests/django
# MariaDB
mysqladmin create tailslide_test
ADAPTER=mariadb pytest tests/django
# MySQL (install the extension first)
mysqladmin create tailslide_test
ADAPTER=mysql pytest tests/django
# SQL Server
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=YourStrong!Passw0rd' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
docker exec -it <container-id> /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P YourStrong\!Passw0rd -Q "CREATE DATABASE tailslide_test"
ADAPTER=sqlserver pytest tests/django
# MongoDB
pytest tests/mongoengine
Release files for tailslide 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tailslide-0.2.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Release files / tailslide-0.2.0-py2.py3-none-any.whl
| Download URL | tailslide-0.2.0-py2.py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2e91a8fd299380e14f7944caff3d5bb460aabf2772dca1aa04f9270731462d2f
|
|
BLAKE2b-256 checksum How to use checksums |
704c3cf797ab446d121344b8375daafdfade32fc2cae65aa1e004ea6c38e8bc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|