Compare commits

..

3 Commits

Author SHA1 Message Date
049ffb18e5 Bump mysql from 4bc8277 to 720d2a3 (#1)
Bumps [mysql](https://github.com/luapower/mysql) from `4bc8277` to `720d2a3`.
- [Release notes](https://github.com/luapower/mysql/releases)
- [Commits](4bc8277470...720d2a3955)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Co-authored-by: David Leal <halfpacho@gmail.com>
2020-08-19 17:00:27 -05:00
00a0c881a2 Add Travis CI and LuaCheck (#2) 2020-05-06 13:58:07 -05:00
1a36d6a7d5 Improve a bit the code...
..., remove one deprecated function, use mod.conf for name and description.
2019-09-26 16:44:19 -05:00
7 changed files with 45 additions and 7 deletions

19
.luacheckrc Normal file
View File

@ -0,0 +1,19 @@
unused_args = false
allow_defined_top = true
max_line_length = 999
globals ={
"minetest",
}
read_globals = {
string = {fields = {"split", "trim"}},
table = {fields = {"copy", "getn"}},
}
files["init.lua"].ignore = { "modname", "tab" }
files["mysql/mysql.lua"].ignore = { "" }
files["mysql/mysql_h.lua"].ignore = { "" }
files["mysql/mysql_print.lua"].ignore = { "" }
files["mysql/mysql_test.lua"].ignore = { "" }
-- ^ Ignore everything

11
.travis.yml Normal file
View File

@ -0,0 +1,11 @@
language: generic
addons:
apt:
packages:
- luarocks
before_install:
- luarocks install --local luacheck
script:
- $HOME/.luarocks/bin/luacheck .
notifications:
email: false

View File

@ -1,4 +1,5 @@
# mysql_base
[![Build Status](https://travis-ci.org/MinetestForFun/mysql_base.svg)](https://travis-ci.org/MinetestForFun/mysql_base)
Base Minetest mod to connect to a MySQL database. Used by other mods to read/write data.

View File

@ -1,5 +1,4 @@
local modname = minetest.get_current_modname()
local thismod = _G[modname]
---- Table creation & deletion
@ -33,6 +32,7 @@ function thismod.create_table_sql(name, params)
end
return 'CREATE TABLE ' .. name .. ' (' .. table.concat(lines, ',') .. ')'
end
function thismod.create_table(name, params)
thismod.conn:query(thismod.create_table_sql(name, params))
end
@ -40,6 +40,7 @@ end
function thismod.drop_table_sql(name)
return 'DROP TABLE ' .. name
end
function thismod.drop_table(name)
thismod.conn:query(thismod.drop_table_sql(name))
end
@ -96,6 +97,7 @@ end
function thismod.prepare_select_sql(tablename, colnames, where)
return 'SELECT ' .. table.concat(colnames, ',') .. ' FROM ' .. tablename .. ' WHERE ' .. where
end
function thismod.prepare_select(tablename, cols, where, wheretypes)
local colnames, coltypes = {}, {}
for _, col in ipairs(cols) do
@ -104,4 +106,4 @@ function thismod.prepare_select(tablename, cols, where, wheretypes)
end
local stmt = thismod.conn:prepare(thismod.prepare_select_sql(tablename, colnames, where))
return stmt, stmt:bind_params(wheretypes), stmt:bind_result(coltypes)
end
end

View File

@ -1,5 +1,5 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local modpath = minetest.get_modpath(modname)
local thismod = {
enabled = false,
@ -11,12 +11,14 @@ function thismod.mklog(level, modname)
minetest.log(level, "[" .. modname .. "] " .. str)
end
end
local LogI = thismod.mklog('action', modname)
local LogE = thismod.mklog('error', modname)
local singleplayer = minetest.is_singleplayer() -- Caching is OK since you can't open a game to
-- multiplayer unless you restart it.
if minetest.setting_get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then
if minetest.settings:get(modname .. '.enable_singleplayer') ~= 'true' and singleplayer then
LogI("Not enabling because of singleplayer game")
return
end
@ -67,7 +69,7 @@ local function string_splitdots(s)
local word_bound = i - 1
table.insert(temp, string.sub(s, index, word_bound))
index = next_index
else
else
if index > 0 and index <= last_index then
table.insert(temp, string.sub(s, index, last_index))
elseif index == 0 then
@ -202,6 +204,7 @@ local function ping()
end
minetest.after(1800, ping)
end
minetest.after(10, ping)
local shutdown_callbacks = {}
@ -229,4 +232,4 @@ function thismod.table_exists(name)
return exists
end
dofile(modpath .. '/abstraction.lua')
dofile(modpath .. '/abstraction.lua')

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = mysql_base
description = MySQL connector (requires LuaJIT FFI).

2
mysql

Submodule mysql updated: 4bc8277470...720d2a3955