summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/data/database.lua
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2018-01-14 08:39:37 -0600
committer cracyc <cracyc@users.noreply.github.com>2018-01-14 08:39:37 -0600
commit380bff22029f3088e026687df2a0d39c4915f58b (patch)
treeecf7526030ad1645398b99d00c3cebe79a93f99d /plugins/data/database.lua
parentcea7ff08ace1cadc22d80074c6c734568a2ad93e (diff)
plugins/data: don't pollute the namespace and use emu.print_error (nw)
Diffstat (limited to 'plugins/data/database.lua')
-rw-r--r--plugins/data/database.lua11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/data/database.lua b/plugins/data/database.lua
index 9e1fd7ae855..aff74c9bc87 100644
--- a/plugins/data/database.lua
+++ b/plugins/data/database.lua
@@ -2,9 +2,9 @@ local sql = require("lsqlite3")
local datfile = {}
local db
-function check_db(msg)
- if db:errcode() > sqlite3.OK then
- io.stderr:write("Error: " .. msg .. " (" .. db:errcode() .. " - " .. db:errmsg() .. ")\n")
+local function check_db(msg)
+ if db:errcode() > sql.OK then
+ emu.print_error("Error: " .. msg .. " (" .. db:errcode() .. " - " .. db:errmsg() .. ")\n")
end
end
@@ -31,4 +31,7 @@ if db then
end
end
-return function() return db, sql end
+local dbtable = { prepare = function(...) return db:prepare(...) end,
+ exec = function(...) return db:exec(...) end, ROW = sql.ROW, check = check_db }
+
+return db and dbtable or nil