local _M = {}
local luasql = require "luasql.mysql"
local json = require "cjson";
_M['date'] = os.date('%Y-%m-%d %H:%M:%S')
local db = "log"
local db_user = "3proxy"
local db_password = "645zzz"	
local env = assert(luasql.mysql())
local con = assert(env:connect(db,db_user,db_password))

function _M.cursor(data)
	return assert(con:execute(data))
end

function _M.results(cur)	
	local results = {}
	if not cur then return results end
	local i = 1
	row = cur:fetch({},"a")
	while row do
		results[i] = {}
		for key,val in pairs(row) do
			results[i][key] = val
		end
		row = cur:fetch (row, "a")
		i = i + 1
	end
	cur:close()
	--con:close()
	--env:close()
	return results
end

return _M
