RetroArch/libretro-db/README.md

69 lines
1.9 KiB
Markdown
Raw Normal View History

2015-01-23 04:59:47 +00:00
# libretrodb
2014-12-30 20:02:15 +00:00
A small read only database
Mainly to be used by retroarch
# Usage
2015-01-19 21:47:09 +00:00
Files specified later in the chain **will override** earlier ones if the same key exists multiple times.
2014-12-30 20:02:15 +00:00
2015-01-23 04:59:47 +00:00
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>`
2014-12-30 20:02:15 +00:00
2015-01-07 17:34:37 +00:00
# lua converters
In order to write you own converter you must have a lua file that implements the following functions:
~~~.lua
2015-01-24 10:17:03 +00:00
-- this function gets called before the db is created and should validate the
2015-01-07 17:34:37 +00:00
-- 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
~~~
2015-01-19 21:47:09 +00:00
# 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
~~~
2015-01-20 02:36:50 +00:00
# Query examples
2015-01-23 04:59:47 +00:00
Some examples of queries you can use with libretrodbtool:
2015-01-20 02:36:50 +00:00
1) Glob pattern matching
2015-01-20 18:36:36 +00:00
Usecase : Search for all games starting with 'Street Fighter' in the 'name' field (glob pattern matching)
2015-01-20 02:36:50 +00:00
2015-01-23 04:59:47 +00:00
`libretrodb_tool <db file> find "{'name':glob('Street Fighter*')}"`
2015-01-20 02:36:50 +00:00
2) Combined number matching query
Usecase: Search for all games released on October 1995.
2015-01-23 04:59:47 +00:00
`libretrodb_tool <db file> find "{'releasemonth':10,'releaseyear':1995}"`
2015-01-20 02:36:50 +00:00