OCGDB (Open Chess Game Database Standard) is a free, open format for game databases, plus the console programs that make and use them. A database is an ordinary SQLite file: games, players, events and sites are plain tables, so any SQLite tool, in any language, can open and query it. Code and format are MIT-licensed.
OCGDB is one of the pearls of Banksia GUI and MoonRiver (a Xiangqi, Jieqi chess GUI). It is the database inside them: their Database Viewer, their database builder and their PQL position search all work on OCGDB databases. Version 2.0 brings the same code to the command line, as two small programs with no GUI and nothing else to install.
Download / source: https://github.com/nguyenpham/ocgdb (ready-to-run programs for Windows, macOS and Linux: https://github.com/nguyenpham/ocgdb/rel ... Version2.0)
What is new
- Xiangqi and jieqi. A second program, ocgdb-xq, does everything ocgdb does for xiangqi (Chinese chess) and jieqi (xiangqi with covered pieces). Chess960 is supported too (-variant chess960).
- A much stronger PQL (Position Query Language). Besides pieces and squares it now searches moves (move[...], capture, promotion, check, mate), lines (line[...]), sequences (then), not and brackets. "Three White queens on the board", "mate by a knight", "games opening with the central cannon" are one short query each, and each game found comes with the ply where it matched.
- Variations and comments are stored and exported.
- New tasks. -sql runs any SQL query, -info describes a database, -merge adds games from PGN files or from other databases; -where filters an export with SQL.
- Encryption. Databases can be protected with a password (SQLite3 Multiple Ciphers), the same scheme as Banksia GUI and MoonRiver, so a password set in one opens in the others.
- Correct and repeatable. Game IDs follow the order of the PGN files however many threads run; PGN tags are read and written with the PGN standard's escapes; duplicate removal always keeps the first copy and does not take transpositions for copies.
- Much more stable and reliable. Many bugs were fixed in version 2, so OCGDB is now much more stable and reliable, especially when a database is read and written from several points at the same time (many threads creating, merging, searching and exporting together).
- Fast. On an Apple M1 Pro with 8 threads: 17,700 chess games a second when creating a database, a PQL search through 8 million games in about a minute, 135,030 xiangqi games turned into a database in 4.5 s.
- Old databases still work. Databases made by OCGDB 1.x are read as they are.
You do not need to build a database to try OCGDB. Large, free databases in this format are published on two hubs, and Banksia GUI and MoonRiver install them from Tools › Download:
- BanksiaChessHub (chess)
- Banksia Masters: 8,008,264 games between human players, 1801 onwards, names in FIDE style, duplicates removed (855 MB download, 1.87 GB unpacked).
- Lichess Puzzles: 2,440,210 Lichess puzzles as games, with rating and themes (148 MB).
- MoonRiverChineseChessHub (xiangqi)
- MoonRiver Masters: 135,030 xiangqi games between human players, 1905 onwards, duplicates removed (14.8 MB download, 31.3 MB unpacked).
How to use it
Download the programs from the release page, or build them:
Code: Select all
git clone https://github.com/nguyenpham/ocgdb.git
cd ocgdb/src
make -j8 # -> src/ocgdb and src/ocgdb-xqCode: Select all
gh release download banksiamasters-db -R nguyenpham/BanksiaChessHub
7z x banksiamasters.ocgdb.db3.7z
ocgdb -info -db banksiamasters.ocgdb.db3
ocgdb -db banksiamasters.ocgdb.db3 -q "Q = 3" # three White queens at some moment
ocgdb -db banksiamasters.ocgdb.db3 -q "mate and move[N, n]" # mates by a knight
ocgdb -export -db banksiamasters.ocgdb.db3 -pgn fischer.pgn \
-where "w.Name = 'Fischer, Robert' OR b.Name = 'Fischer, Robert'"
ocgdb-xq -db moonrivermasters.ocgdb.db3 -q "line[h2e2]" # games opening with the central cannonCode: Select all
ocgdb -db banksiamasters.ocgdb.db3 -sql "SELECT Result, COUNT(*) FROM Games GROUP BY Result ORDER BY 2 DESC"Code: Select all
ocgdb -create -pgn mygames.pgn -db mygames.ocgdb.db3Comments, bug reports and pull requests are welcome at https://github.com/nguyenpham/ocgdb/issues.
My blog post: https://banksiagui.com/ocgdb-new-versio ... and-jieqi/
Older forum posts here: viewtopic.php?t=78464
