You could use callbacks to avoid that
an example from the wiki:
local dbConnection = dbConnect("sqlite", "sql.db")
function onServerCallback(queryHandler, extraData)
local queryResult = dbPoll(queryHandler, 0)
print(extraData)
if type(queryResult) == "table" then
print("queryResult == table")
if #queryResult > 0 then
print("#queryResult > 0")
else
print("#queryResult == 0")
end
else
print("queryResult ~= table")
end
end
dbQuery(onServerCallback, {"Extra data :)"}, dbConnection, "SELECT * FROM `Players` WHERE `playerName` = ?", "playerName")