Another recommendation is that you may need to not use sql db to do this but instead export all the data in JSON; this is actually what most commercial games with lots of data do. Then with the Lua plugin you may be able to load, parse and organize the data.