Skip to main content

Command-line utility for counting records that refer to a database table in MySQL.

Project description


CountRecordRefs is a command-line tool for counting related records in a MySQL database. The program outputs the number of records for each foreign key column.

The code is written in Python and should work with both Python 2 and 3.

Source repository:

<nav class="contents local" id="table-of-contents" role="doc-toc">

Table of contents



Apart from MySQL itself, you only need to have the Python package PyMySQL installed. If you install CountRecordRefs following the instructions below, PyMySQL will be installed automatically for you.


The project is hosted at and can be installed using git:

$ git clone
$ cd CountRecordRefs
$ python install

You may consider installing CountRecordRefs within a virtual environment in order to avoid cluttering your system’s Python path. See for example the environment management system conda or the package virtualenv.

This project is centered around a self-contained single-module (single-file) executable script that can also be used as such.


usage: [-h] [-V] [--user USER] [--password PASSWORD]
                          [--host HOST] [-z]
                          database_name table_name id

Command-line utility for counting related records in a MySQL database. Output
is written to <stdout>.

positional arguments:
  database_name        MySQL database name
  table_name           table name
  id                   primary key value to look up

optional arguments:
  -h, --help           show this help message and exit
  -V, --version        show program's version number and exit
  --user USER          MySQL user (default: "root")
  --password PASSWORD  MySQL password
  --host HOST          database host (default: "localhost")
  -z, --zero-counts    include counts of zero in output


CountRecordRefs is distributed under the GNU General Public License, version 3 (GPL-3.0).


Markus Englund,

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CountRecordRefs-0.2.1.tar.gz (17.8 kB view hashes)

Uploaded source

Built Distribution

CountRecordRefs-0.2.1-py3-none-any.whl (6.5 kB view hashes)

Uploaded any

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page