semvec/pypi-packages huggingface dataset:
hightop 0.2.0
A nice shortcut for group count queries with Django
License: MIT
Requires Python: >=3.8

# Hightop.py

A nice shortcut for group count queries with Django

```python
Visit.objects.top('browser')
# {
#   'Chrome': 63,
#   'Safari': 50,
#   'Firefox': 34
# }
```

[![Build Status](https://github.com/ankane/hightop.py/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/hightop.py/actions)

## Installation

Run:

```sh
pip install hightop
```

## Getting Started

Add a [custom manager](https://docs.djangoproject.com/en/3.2/topics/db/managers/) to the models where you want to use it.

```python
from hightop import HightopQuerySet

class Visit(models.Model):
    objects = HightopQuerySet.as_manager()
```

And query away

```python
Visit.objects.top('browser')
```

## Options

Limit the results

```python
Visit.objects.top('referring_domain', 10)
```

Include null values

```python
Visit.objects.top('search_keyword', null=True)
```

Works with multiple groups

```python
Visit.objects.top(['city', 'browser'])
```

And expressions

```python
Visit.objects.top(Lower('referring_domain'))
```

And distinct

```python
Visit.objects.top('city', distinct='user_id')
```

And min count

```python
Visit.objects.top('city', min=10)
```

## History

View the [changelog](https://github.com/ankane/hightop.py/blob/master/CHANGELOG.md)

## Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

- [Report bugs](https://github.com/ankane/hightop.py/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/hightop.py/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features

To get started with development:

```sh
git clone https://github.com/ankane/hightop.py.git
cd hightop.py
pip install -r requirements.txt
pytest
```
tailslide 0.2.0
Median and percentile for Django and MongoEngine
License: MIT
Requires Python: >=3.8

# 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

[![Build Status](https://github.com/ankane/tailslide/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/tailslide/actions)

## Installation

Run:

```sh
pip install tailslide
```

For MySQL, also follow [these instructions](#additional-instructions).

## Getting Started

- [Django](#django)
- [MongoEngine](#mongoengine)

### Django

Median

```python
from tailslide import Median

Item.objects.aggregate(Median('price'))
```

Percentile

```python
from tailslide import Percentile

Request.objects.aggregate(Percentile('response_time', .95))
```

Works with grouping, too, with PostgreSQL, MySQL, and SQLite

```python
Order.objects.values('store').annotate(total=Median('total')).order_by('store')
```

### MongoEngine

Add a [custom QuerySet](https://docs.mongoengine.org/guide/querying.html#custom-querysets) to the models where you want to use it.

```python
from tailslide.mongoengine import TailslideQuerySet

class Item(Document):
    meta = {'queryset_class': TailslideQuerySet}
```

Median

```python
Item.objects.median('price')
```

Percentile

```python
Item.objects.percentile('price', .95)
```

## Additional Instructions

### MySQL

MySQL requires the `PERCENTILE_CONT` function from [udf_infusion](https://github.com/infusion/udf_infusion). To install it, do:

```sh
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](https://github.com/ankane/tailslide/blob/master/CHANGELOG.md)

## Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

- [Report bugs](https://github.com/ankane/tailslide/issues)
- Fix bugs and [submit pull requests](https://github.com/ankane/tailslide/pulls)
- Write, clarify, or fix documentation
- Suggest or add new features

To get started with development:

```sh
git clone https://github.com/ankane/tailslide.git
cd tailslide
pip install -r requirements.txt
```

To run the tests:

```sh
# 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
```