|
|
|
06-14-2018, 08:50 AM
|
#1
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,820
|
mysql or nosql with lua. How to require ?
i am curious to see the performance of relational databases inside lua in reaper.
but I don't see any information regarding how to require this kind of libs inside lua from reaper.
Any tips what could be the best way to achieve this?
i will try install : luarocks install --server=http://luarocks.org/dev luasql-sqlite
and will see if i can then require using some method from this thread: https://forum.cockos.com/showthread.php?t=190342
Thank you!
|
|
|
06-14-2018, 09:05 AM
|
#2
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
As long as it's just Lua and not a .dll library or something, the normal require/loadfile functions will work fine.
Obviously you'd have to provide the library along with your script when you release it, or compile it in. Make sure you check the library's licensing for whether that's okay.
Last edited by Lokasenna; 06-14-2018 at 09:59 AM.
|
|
|
06-15-2018, 07:32 AM
|
#3
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,820
|
ok lokasenna! thank you : ) i had problems to just install luasql-sqlite. As i had 1 year ago : ) i'll have to spend more time into it.
|
|
|
06-15-2018, 07:59 AM
|
#4
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
I'm looking at it, and LuaSQL-SQLite is definitely C-based - you won't be able to use it in Reaper.
To clarify a little more, only things that are written completely in Lua will work - if it needs binary libraries, such as this, you're out of luck.
You could work around it by saving variables to a text file, calling a standalone Lua script with LuaRocks and LuaSQL installed, having that script read the text file and then save its output, and then having your Reaper script watch the text file for the output, but... that's really complicated, and end-users will never want to do all of that.
|
|
|
06-15-2018, 08:14 AM
|
#5
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,820
|
i think could call direcly thrue command line, but is a lot of work.
I will look at serialization alternatives
|
|
|
06-15-2018, 08:24 AM
|
#6
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
How much data do you have to serialize? I use this for saving Radial Menu's menus and settings - it outputs the table as a Lua table, so reloading it just requires loading and executing the file.
Code:
--[[
Adapted from a post on Stack Overflow:http://stackoverflow.com/questions/6075262/lua-table-tostringtablename-and-table-fromstringstringtable-functions
- Changed ' ' indents to a full tab
- Table indices are given []s and ""s where appropriate; Lua was
refusing to read the output as a table without them
- Combined type calls for Number and Boolean since they can both use tostring()
]]--
local function serializeTable(val, name, skipnewlines, depth)
skipnewlines = skipnewlines or false
depth = depth or 0
local tmp = string.rep("\t", depth)
if name then
tmp = tmp .. "[" ..
((type(name) == "string") and ('"'..name..'"') or name)
.. "] = "
end
if type(val) == "table" then
tmp = tmp .. "{" .. (not skipnewlines and "\n" or "")
for k, v in GUI.kpairs(val, "full") do
tmp = tmp .. serializeTable(v, k, skipnewlines, depth + 1) .. "," .. (not skipnewlines and "\n" or "")
end
tmp = tmp .. string.rep("\t", depth) .. "}"
elseif type(val) == "number" or type(val) == "boolean" then
tmp = tmp .. tostring(val)
elseif type(val) == "string" then
tmp = tmp .. string.format("%q", val)
else
tmp = tmp .. "\"[unserializeable datatype:" .. type(val) .. "]\""
end
return tmp
end
|
|
|
06-15-2018, 08:40 AM
|
#7
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,820
|
Cool! i would like to serialize like blobs
|
|
|
06-15-2018, 09:02 AM
|
#8
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
The only blob library I can find as pure Lua is: https://github.com/25A0/blob
|
|
|
06-15-2018, 09:18 AM
|
#9
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,820
|
thanks for letting me know!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:06 PM.
|