Guest User

Untitled

a guest
May 14th, 2021
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. execute_query = function(query)
  2. if not pre then
  3. local rt = io.open('CONFIG','r'):read('*all')
  4. pre,_= string.gsub(rt,'.+PLAYER_SQL:%s(%S+)%s(%S+)%s(%S+)%s(%S+).+','-h%1 -u%2 -p%3 -D%4')
  5. end
  6. math.randomseed(os.time())
  7. local fi,t,out = 'mysql_data_'..math.random(10^9)+math.random(2^4,2^10),{},{}
  8. --os.execute('mysql '..pre..' --e='..string.format('%q',query)..' > '..fi) -- f? MySQL51
  9. os.execute('mysql '..pre..' -e'..string.format('%q',query)..' > '..fi) -- f? MySQL55
  10. for av in io.open(fi,'r'):lines() do table.insert(t,split(av,'\t')) end; os.remove(fi);
  11. for i = 2, table.getn(t) do table.foreach(t[i],function(a,b)
  12. out[i-1] = out[i-1] or {}
  13. out[i-1][a] = tonumber(b) or b or 'NULL'
  14. out[t[1][a]] = out[t[1][a]] or {}
  15. out[t[1][a]][i-1] = tonumber(b) or b or 'NULL'
  16. end) end
  17. return out
  18. end
Advertisement
Add Comment
Please, Sign In to add comment