libretro-db/README.md
A small read only database Mainly to be used by retroarch
Files specified later in the chain will override earlier ones if the same key exists multiple times.
libretrodb_tool <db file> listlibretrodb_tool <db file> create-index <index name> <field name>libretrodb_tool <db file> find <index name> <value>c_convertergit clone https://github.com/libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
cd retroarch
./configure
cd libretro-db
c_converter "NAME_OF_RDB_FILE.rdb" "NAME_OF_SOURCE_DAT.dat"
c_converterSpecify rom.crc as the second parameter to use CRC as the unique fingerprint.
git clone https://github.com/libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
cd retroarch
./configure
cd libretro-db
c_converter "NAME_OF_RDB_FILE.rdb" "rom.crc" "NAME_OF_SOURCE_DAT_1.dat" "NAME_OF_SOURCE_DAT_2.dat" "NAME_OF_SOURCE_DAT_3.dat"
This approach builds and uses the c_converter program to compile the databases
git clone https://github.com/libretro/libretro-super.git
cd libretro-super
./libretro-fetch.sh retroarch
./libretro-build-database.sh
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
Some examples of queries you can use with libretrodbtool:
libretrodb_tool <db file> find "{'name':glob('Street Fighter*')}"
libretrodb_tool <db file> find "{'releasemonth':10,'releaseyear':1995}"
libretrodb_tool <db file> find "{'crc':b'31B965DB'}"
libretrodb_tool <db file> get-names "{'releasemonth':10,'releaseyear':1995}"
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