MySQL Query and wait


When i am running mysql query with q:wait(), the server freezes and in result, it crashes. Is there someway i can create another thread that if it would freeze it wont affect server?


You better use callbacks for this, lua is not threaded.

Can you provide me an example?

-- Callbacks
Query.onAborted( q )
-- Called when the query is aborted.

Query.onError( q, err, sql )
-- Called when the query errors, [String] err is the error and [String] sql is the SQL query that caused it.

Query.onSuccess( q, data )
-- Called when the query is successful, [Table] data is the data the query returned.

Query.onData( q, data )
-- Called when the query retrieves a row of data, [Table] data is the row.

Well how would i return the result from function which is in function?

It works same as hooks.