summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/data/database.lua
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-07-30 21:33:23 -0500
committer cracyc <cracyc@users.noreply.github.com>2017-07-30 21:33:23 -0500
commit83adc109e7b70dad4bd12e2fa1b6877f41e7c94c (patch)
tree5b4ee835531c7af9631acfdc421bd96fcb8e0cb8 /plugins/data/database.lua
parent25e6589df601d58fc25ba0be56fe7bd49f2f7e0e (diff)
plugins/data: add marp scores [Carl]
Diffstat (limited to 'plugins/data/database.lua')
-rw-r--r--plugins/data/database.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/data/database.lua b/plugins/data/database.lua
new file mode 100644
index 00000000000..4f55e999be2
--- /dev/null
+++ b/plugins/data/database.lua
@@ -0,0 +1,24 @@
+local sql = require("lsqlite3")
+local datfile = {}
+local db
+do
+ local dbpath = lfs.env_replace(mame_manager:ui():options().entries.historypath:value():match("([^;]+)"))
+ db = sql.open(dbpath .. "/history.db")
+ if not db then
+ lfs.mkdir(dbpath)
+ db = sql.open(dbpath .. "/history.db")
+ end
+end
+
+if db then
+ local found = false
+ db:exec("select * from sqllite_master where name = version", function() found = true return 0 end)
+ if not found then
+ db:exec([[
+ CREATE TABLE version (
+ version VARCHAR NOT NULL,
+ datfile VARCHAR UNIQUE NOT NULL)]])
+ end
+end
+
+return function() return db, sql end