RetroArch/libretro-db
Twinaphex 5ba28b60aa
Merge pull request #5699 from meepingsnesroms/master
Properly clean up memory on exit(libretrodb_tool)
2017-11-18 10:18:14 +01:00
..
lua Try to avoid directly calling strcmp 2017-04-21 13:56:15 +02:00
bintree.c Header update #1 2017-01-22 13:40:32 +01:00
bintree.h Header update #1 2017-01-22 13:40:32 +01:00
c_converter_test.sh (libretro-db) c_converter: implement a binary search tree, improves 2016-01-24 03:16:25 +01:00
c_converter.c Update RDB building to ignore missing keys 2017-06-07 10:43:56 -04:00
dat_converter Change this back 2016-01-26 08:41:07 +01:00
libretrodb_tool.c Properly clean up memory on exit(libretrodb_tool) 2017-11-17 16:44:15 -08:00
libretrodb.c Cleanups 2017-10-04 06:53:47 +02:00
libretrodb.h Header update #1 2017-01-22 13:40:32 +01:00
Makefile Fix db build 2017-08-17 01:06:18 +01:00
query.c Silence more Clang warnings 2017-10-11 22:49:13 +02:00
query.h Header update #1 2017-01-22 13:40:32 +01:00
README.md Add option to search libretro databases and only print game name 2017-11-15 16:42:22 -08:00
rmsgpack_dom.c Wipe out a buncha warnings and pointless ifdefs (some warnings will remain until #5497 is fixed) 2017-10-03 00:26:29 +02:00
rmsgpack_dom.h Header update #1 2017-01-22 13:40:32 +01:00
rmsgpack_test.c only call setvbuf right after opening file, and use our own buffer for C89 compliance 2017-11-17 02:28:45 -05:00
rmsgpack.c Header update #1 2017-01-22 13:40:32 +01:00
rmsgpack.h Header update #1 2017-01-22 13:40:32 +01:00

libretrodb

A small read only database Mainly to be used by retroarch

Usage

Files specified later in the chain will override earlier ones if the same key exists multiple times.

To list out the content of a db libretrodb_tool <db file> list To create an index libretrodb_tool <db file> create-index <index name> <field name> To find an entry with an index libretrodb_tool <db file> find <index name> <value>

lua converters

In order to write you own converter you must have a lua file that implements the following functions:

-- this function gets called before the db is created and should validate the
-- arguments and set up the ground for db insertion
function init(...)
	local args = {...}
	local script_name = args[1]
end

-- this is in iterator function. It is called before each insert.
-- the function should return a table for insertion or nil when there are no
-- more records to insert.
function get_value()
	return {
		key = "value", -- will be saved as string
		num = 3, -- will be saved as int
		bin = binary("some string"), -- will be saved as binary
		unum = uint(3), -- will be saved as uint
		some_bool = true, -- will be saved as bool
	}
end

dat file converter

To convert a dat file use:

dat_converter <db file> <dat file>

If you want to merge multiple dat files you need to run:

dat_converter <db file> <match key> <dat file> ...

for example:

dat_converter snes.rdb rom.crc snes1.dat snes2.dat

Query examples

Some examples of queries you can use with libretrodbtool:

  1. Glob pattern matching Usecase : Search for all games starting with 'Street Fighter' in the 'name' field (glob pattern matching)

libretrodb_tool <db file> find "{'name':glob('Street Fighter*')}"

  1. Combined number matching query Usecase: Search for all games released on October 1995.

libretrodb_tool <db file> find "{'releasemonth':10,'releaseyear':1995}"

  1. Names only search Usecase: Search for all games released on October 1995, wont print checksums, filename or rom size, only the game name.

libretrodb_tool <db file> get-names "{'releasemonth':10,'releaseyear':1995}"

Compiling the Database

Use libretro-super to compile the entire database:

git clone git@github.com:libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
./libretro-build-database.sh