1
0
mirror of https://github.com/quay/quay.git synced 2026-01-26 06:21:37 +03:00
Files
quay/data/estimate.py
Brandon Caton ef91c57c23 format: Updating black to resolve click dependency issue (PROJQUAY-3487) (#1209)
Currently the CI breaks due to a dependency of black, `click`, breaking with it's latest release with `ImportError: cannot import name '_unicodefun' from 'click'`. Since black does not pin it's version of click it pulls in the latest version containing the breaking change and fails the CI check. This updates black with the patch. [See the original issue here.](https://github.com/psf/black/issues/2964) The rest of the changes are format updates introduced with the latest version of black.
2022-03-29 15:34:57 -04:00

12 lines
498 B
Python

def mysql_estimate_row_count(model_cls, db):
"""Uses the information_schema to retrieve the row count for a table."""
query = "SELECT table_rows FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = %s"
cursor = db.execute_sql(query, (model_cls._meta.table_name,))
res = cursor.fetchone()
return res[0]
def normal_row_count(model_cls, db):
"""Uses a normal .count() to retrieve the row count for a model."""
return model_cls.select().count()