Track, store and query your PyPI package download statistics
Project description
pkgdb
Track PyPI package download statistics. Fetches download stats via the pypistats API, stores historical data in SQLite, and generates HTML reports with charts.
Installation
pip install pkgdb
To build:
Requires Python 3.10+. Uses uv for dependency management.
uv sync
Usage
Configure packages
Edit packages.yml to list the packages you want to track:
published:
- my-package
- another-package
Commands
# Fetch latest stats from PyPI and store in database
pkgdb fetch
# Display stats in terminal (includes trend sparklines and growth %)
pkgdb list
# Show historical stats for a specific package
pkgdb history <package-name>
# Generate HTML report with charts (opens in browser)
pkgdb report
# Generate detailed HTML report for a single package
pkgdb report <package-name>
# Include environment summary (Python versions, OS) in report
pkgdb report -e
# Export stats in various formats
pkgdb export -f csv # CSV format (default)
pkgdb export -f json # JSON format
pkgdb export -f markdown # Markdown table
# Show detailed stats for a package (Python versions, OS breakdown)
pkgdb stats <package-name>
# Fetch stats and generate report in one step
pkgdb update
Options
# Use custom database file
pkgdb -d custom.db fetch
# Use custom packages file
pkgdb -p custom.yml fetch
# Specify output file for report
pkgdb report -o custom-report.html
# Limit history output to N days
pkgdb history my-package -n 14
# Export to file instead of stdout
pkgdb export -f json -o stats.json
Architecture
Single-file CLI application with seven commands:
- fetch: Calls
pypistats.recent()andpypistats.overall()for each package, stores results in SQLite - list: Queries latest stats per package with trend sparklines and growth metrics
- history: Shows historical data for a specific package over time
- report: Generates self-contained HTML report with SVG charts (bar charts + time-series). With
-eflag, includes Python version and OS distribution summary. With package argument, generates detailed single-package report - export: Exports stats in CSV, JSON, or Markdown format
- stats: Shows detailed breakdown (Python versions, OS) for a single package
- update: Runs fetch then report
Data flow
packages.yml -> pypistats API -> SQLite (pkg.db) -> HTML/terminal output
Database schema
The package_stats table stores:
package_name: Package identifierfetch_date: Date stats were fetched (YYYY-MM-DD)last_day,last_week,last_month: Recent download countstotal: Total downloads (excluding mirrors)
Stats are upserted per package per day, so running fetch multiple times on the same day updates rather than duplicates.
Files
pkgdb.py: Main CLI applicationpackages.yml: Package list configurationpkg.db: SQLite database (auto-created)report.html: Generated HTML report (default output)
Development
# Install dev dependencies
uv sync
# Run tests
pytest
# Run tests with verbose output
pytest -v
Dependencies
Runtime:
pypistats: PyPI download statistics API clientpyyaml: YAML configuration parsingtabulate: Terminal table formatting
Development:
pytest: Testing framework
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pkgdb-0.1.0.tar.gz.
File metadata
- Download URL: pkgdb-0.1.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a40812e4e6f467f260b859206a11e23e0fd9350e6b6c45b1db5b2e33d7bc3726
|
|
| MD5 |
f358d662f8ed3618bc14da6b8ef72b38
|
|
| BLAKE2b-256 |
f0fdd23ea3ecea4085594cd1f4e08ae92b10b5b6ff516c21a0551e4f591d4ae4
|
File details
Details for the file pkgdb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pkgdb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
023d5f576943f38bdd7169feee876335634a1e71c7b656ae7a8a688ec85cad0b
|
|
| MD5 |
163609de12bef3f43127a548e5e6ef37
|
|
| BLAKE2b-256 |
4c30c9a1cba2a254471df8fe17db578f0ef1efb7801fe0fa303d9eabfbc2cdb3
|