Pull your Chess games from chess.com and lichess.org into a sqlite3 database.
Project description
PGN to SQLite
A CLI application for pulling PGN files from Chess.com and Lichess.org and saving your games into a SQLite database.
It can also be used to save PGN files from a local folder to a SQLite database.
Requirements
Python 3.10 or higher is required.
Installation
It is recommended that you install this package in a virtual or isolated environment. The easiest way to do this is with uv:
uv tool install pgn_to_sqlite
Alternatively, you can install it with pipx:
pipx install pgn_to_sqlite
Or with pip:
pip install pgn_to_sqlite
Usage
Usage: pgn-to-sqlite [OPTIONS] COMMAND [ARGS]...
Save your chess games to a SQLite database.
You can `fetch` your games from chess.com or lichess.org. You can also
`save` local PGN files to the database.
Options:
-u, --user TEXT Your username for the chess site.
-o, --output FILE Where you would like your database saved. [required]
--help Show this message and exit.
Commands:
fetch Fetch all games from the requested site.
save Save all PGN files from the given folder.
Fetching Games from Chess.com or Lichess.org
To download, parse, and save your games, both --user and --output are required. The fetch command accepts either chess or lichess as an argument for Chess.com and Lichess.org respectively.
Example:
pgn-to-sqlite -u endlesstrax -o games.db fetch lichess
Note: If you've played a lot of games, be patient—it could take a minute or two to download and process them all.
Saving Games from a Local Folder
To save games from local PGN files to your database, only --output is required. The save command expects a folder path as an argument.
Example:
pgn-to-sqlite -o games.db save ./chess/games/
Development
This project uses uv for dependency management and development workflows.
Setting Up Your Development Environment
-
Install
uvif you haven't already:pip install uv
-
Clone the repository:
git clone https://github.com/EndlessTrax/pgn-to-sqlite.git cd pgn-to-sqlite
-
Sync dependencies and set up the virtual environment:
uv sync
Running Tests
Run the test suite with:
uv run pytest
For coverage reporting:
uv run pytest --cov
Linting and Formatting
This project uses Ruff for linting and formatting:
# Check for issues
uv run ruff check .
# Format code
uv run ruff format .
Building the Project
To build the package:
uv build
Contributing
Contributions are welcome! Please follow these guidelines:
-
File an issue first - Before making a PR, please file an issue so the implementation can be discussed. This saves time and increases the chances of your PR being merged without significant changes.
-
Lint and format your code - Use
uv run ruff check .anduv run ruff format .to ensure your code follows the project's style guidelines. -
Include tests - Please include tests for any code changes (unless current tests already cover your contribution).
-
Update documentation - If your changes affect usage, please update the README accordingly.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
If you find this project useful and would like to show your support, you can:
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 pgn_to_sqlite-2.3.0.tar.gz.
File metadata
- Download URL: pgn_to_sqlite-2.3.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6eb0211145d793b6d3db3d779982a14a090cd94e55b4ec933f395e62b339c6d4
|
|
| MD5 |
c93e1405961d1e637cbfbef2afdca8fb
|
|
| BLAKE2b-256 |
39d005ac3cfac34049054df01bedd65370b6b8c280e535c687daddeb7517ef91
|
File details
Details for the file pgn_to_sqlite-2.3.0-py3-none-any.whl.
File metadata
- Download URL: pgn_to_sqlite-2.3.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
609e351460885dd49fb9006660374e8f3e27ae8c3a39e9c1aa0bd82f6500cbd0
|
|
| MD5 |
42ab203202df9018a68b72555040de4a
|
|
| BLAKE2b-256 |
66bf023560ba6f0b5fe940bf7396606b4977dea974b7d79dfff9ed912f8e7011
|