[Release] MySQL Async Library - 3.3.2

Update 3.0.6

  • Fixes multiple statements partially. See FrBillyD’s, (french) example on how to fix it. e.g.
local result = MySQL.Sync.fetchAll(Query .. Query2, Parameters)
return result[2][1]

when the second query is the select (hence the 2 in the result).

  • Debug print shows now the resource requesting the mysql-query.

I am on a Linux Ubuntu 16.04, after installing your 2.1.1 (because you said linux needs 2.x versions) when I start my server I get this error:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
  at System.Data.Common.DbConnectionOptions.GetKeyValuePair (System.String connectionString, System.Int32 currentPosition, System.Text.StringBuilder buffer, System.Boolean useOdbcRules, System.String& keyname, System.String& keyvalue) [0x000d4] in <1cab2ddf0fb2413491f2679cff202044>:0
  at System.Data.Common.DbConnectionOptions.ParseInternal (System.Collections.Generic.Dictionary`2[TKey,TValue] parsetable, System.String connectionString, System.Boolean buildChain, System.Collections.Generic.Dictionary`2[TKey,TValue] synonyms, System.Boolean firstKey) [0x0001c] in <1cab2ddf0fb2413491f2679cff202044>:0
  at System.Data.Common.DbConnectionOptions..ctor (System.String connectionString, System.Collections.Generic.Dictionary`2[TKey,TValue] synonyms, System.Boolean useOdbcRules) [0x00037] in <1cab2ddf0fb2413491f2679cff202044>:0
  at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString (System.String value) [0x00015] in <1cab2ddf0fb2413491f2679cff202044>:0
  at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor (System.String connectionString) [0x00006] in <149068887d4e4bc08e7b4c05a59a923b>:0
  at MySQLAsync.MySQLAsync.Configure (System.String connectionStringConfig, System.Boolean debug) [0x00000] in <6f835765886c4fada3e5ffb1ffcd6998>:0
  at MySQLAsync.MySQLAsync.<.ctor>b__2_0 () [0x00047] in <6f835765886c4fada3e5ffb1ffcd6998>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <49fde7938a9b47b480042d844e818c7e>:0
   --- End of inner exception stack trace ---
 
 
Server stack trace:
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <49fde7938a9b47b480042d844e818c7e>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <49fde7938a9b47b480042d844e818c7e>:0
  at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e7] in <49fde7938a9b47b480042d844e818c7e>:0
  at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in <49fde7938a9b47b480042d844e818c7e>:0
  at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in <49fde7938a9b47b480042d844e818c7e>:0
  at CitizenFX.Core.FunctionReference.Invoke (System.Int32 reference, System.Byte[] arguments) [0x00061] in /src/code/client/clrcore/FunctionReference.cs:62
  at CitizenFX.Core.InternalManager.CallRef (System.Int32 refIndex, System.Byte[] argsSerialized, System.IntPtr& retvalSerialized, System.Int32& retvalSize) [0x00000] in /src/code/client/clrcore/InternalManager.cs:247
  at (wrapper remoting-invoke-with-check) CitizenFX.Core.InternalManager.CallRef(int,byte[],intptr&,int&)
  at (wrapper xdomain-dispatch) CitizenFX.Core.InternalManager.CallRef(object,byte[]&,byte[]&,int,byte[],int&)
 
Exception rethrown at [0]:
  at (wrapper xdomain-invoke) CitizenFX.Core.InternalManager.CallRef(int,byte[],intptr&,int&)
  at (wrapper remoting-invoke-with-check) CitizenFX.Core.InternalManager.CallRef(int,byte[],intptr&,int&)
  at CitizenFX.Core.MonoScriptRuntime.CallRef (System.Int32 refIndex, System.Byte[] argsSerialized, System.Int32 argsSize, System.IntPtr& retvalSerialized, System.Int32& retvalSize) [0x00013] in /src/code/client/clrcore/MonoScriptRuntime.cs:151
Error running system event handling function for resource mysql-async: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:665: An error happened while calling export mysql_configure of resource mysql-async (citizen:/scripting/lua/MessagePack.lua:830: missing bytes), see above for details
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:665: in method 'mysql_configure'
        lib/init.lua:3: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:175: in function <citizen:/scripting/lua/scheduler.lua:174>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:138>
hitch warning: frame time of 1369 milliseconds

Am I forgetting to install something? (It could be the resource Cops FiveM, thats the only one I have that uses mysql-async to my knowledge)

Since 3.0.5, 3.x works fine.

The bug you are having was fixed in 2.1.2.

Ah ok, thank you, I will change versions! :smiley:

You should probably remove that from the OP and the github readme

Now I get this error when I join:

WARNING: NON-EXISTENT NATIVE 000000004d52fe5b
Error calling system call ref function in resource TODO: TypeError: Cannot read property 'query' of undefined
stack:
TypeError: Cannot read property 'query' of undefined
    at global.exports (mysql-async.js:4973:10)
    at citizen:/scripting/v8/main.js:75:40
Error running system event handling function for resource police: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/scheduler.lua:665: An error happened while calling export mysql_fetch_all of resource mysql-async (citizen:/scripting/lua/MessagePack.lua:830: missing bytes), see above for details
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:665: in method 'mysql_fetch_all'
        @mysql-async/lib/MySQL.lua:143: in field 'fetchAll'
        server/server.lua:115: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:175: in function <citizen:/scripting/lua/scheduler.lua:174>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:174: in function <citizen:/scripting/lua/scheduler.lua:138>

This is get_invoking_resource. Either upgrade your server version or downgrade to 3.0.5

Will do, thanks for the help!

Ok, just updated to the latest server

Now I get this error:


Error: (node:98545) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '3' of null
    at parseConnectingString (mysql-async.js:5027:30)
    at global.on (mysql-async.js:5043:18)
    at citizen:/scripting/v8/main.js:193:28
Error: (node:98545) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
Error: (node:98545) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Just asking because I’ve had issues on here but because of this im wondering if it could be an issue with the addon I installed?

Error: (node:98545) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

This is a parsing failure of the connection string. Try a 2.x connection string, like this:

set mysql_connection_string "server=localhost;uid=mysqluser;password=password;database=fivem"


Help please what to do?

use localhost instead of 127.0.0.1

What do you mean? I used this ip 127.0.0.1

127.0.0.01 is what you wrote. Stop trying to lie to me when it clearly says so in your screenshot. Now go and use localhost instead.

Hi !
I need to make a request in this type:
SELECT * FROM toto WHERE identifier IN(steamid1, steamid2…)

where steamid come from ESX.GetPlayers or GetPlayerIdentifiers()[1]

Hoooooow…with Async can i make that oO ?

i try some syntax but i dont find the good… :’(

and i see in the fivem-mysql-async lua:

assert(type(params) == “table”, “A table is expected”)
assert(params[1] == nil, “Parameters should not be an array, but a map (key / value pair) instead”)

So… ><

Thanks in advance =)

concat all steamids you want and make one parameter out of it.

Thanks Zr0iq

But, I have already try and doenst work, need to encapsulate that in ’ or " ?
In mysql (from php) that work with ’ or " but here i dont understand… oO
I try again and angain, I will end up finding…

local identifiers = ''
local players = ESX.GetPlayers()
for i = 1, #players, 1 do
	local identifier = GetPlayerIdentifiers(players[i])[1]
	if identifiers == nil then
		identifiers = identifier
	else
		identifiers = identifiers .. ", " .. identifier
	end
end
local params = {
	'@identifiers' = identifiers
	}
	if identifiers == nil then
		identifiers = '`' .. identifier .. '`'
	else
		identifiers = identifiers .. ", `" .. identifier .. '`'
	end
MySQL.Async.fetchAll('SELECT * FROM toto WHERE identifier IN(' .. identifiers .. ')', {}, function(results)

end)

my bad if you add identifiers as a parameter it escapes them, if the values in in are escaped. you need to do it manually in this case.

OKAY so I never can found this without your tips !!

Thanks you very much !!

how do i rename the vrpfx to my sql db name?

which version, which scripts, which calls?