[Release] MySQL Async Library - 3.3.2

I have this error someone have the solution ?

Anyone answer you or did you figure it out? I’m in the same boat here

@xander1998 There was a bug in old versions of mysql async it should be resolved on master will do a version in some hours / minutes

@Quentins The error tell it all, connection is impossible : check the host / username / password that you entered in the mysql_connect_string setting

@mandra Not related to mysql, it just say that a Native don’t work :confused:

2.0.0 released read the changelog in the top post

1 Like

great thanks you very much

Hi since we need to use “MySQL.ready”, scripts in this function doesn’t execute anymore :confused:
EDIT : I have found the problem: Citizen.CreateThread Doesn't work serverside

Hi, i am getting an issue with :
image

I have got MySQL working with other scripts using all the same ways just different databases and things like that i have also done the following in my __resource file:
image
But i still continue to get the error here is the cause at line 42 but i cannot see the issue:


Thanks for any help you can give.

Can anyone help, I get the following error:

> [     91843] [ERROR] [mysql-async] An critical error happens on MySQL for query "INSERT INTO users (`identifier`, `money`, `bank`, `group`, `permission_level`, `license`) VALUES (@identifier, @money, @bank, @group, @permission_level, @license); {money=0;identifier=steam:11000010ab482fd;permission_level=0;license=0;bank=CitizenFX.Core.CallbackDelegate;group=user}": Parameter type CallbackDelegate (DbType: AnsiString) not currently supported. Value: CitizenFX.Core.CallbackDelegate   at MySql.Data.MySqlClient.MySqlParameter.AppendSqlString (System.IO.BinaryWriter writer, MySql.Data.MySqlClient.StatementPreparerOptions options) [0x00578] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91859]   at (wrapper remoting-invoke-with-check) MySql.Data.MySqlClient.MySqlParameter:AppendSqlString (System.IO.BinaryWriter,MySql.Data.MySqlClient.StatementPreparerOptions)
>  
> [     91875]   at MySql.Data.MySqlClient.MySqlStatementPreparer+ParameterSqlParser.DoAppendParameter (System.Int32 parameterIndex, System.Int32 textIndex, System.Int32 textLength) [0x00079] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91890]   at MySql.Data.MySqlClient.MySqlStatementPreparer+ParameterSqlParser.OnNamedParameter (System.Int32 index, System.Int32 length) [0x00029] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91906]   at MySql.Data.MySqlClient.MySqlParser.Parse (System.String sql) [0x001be] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91921]   at MySql.Data.MySqlClient.MySqlStatementPreparer.ParseAndBindParameters () [0x0003a] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91921]   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.CreateQueryPayload (System.String commandText, MySql.Data.MySqlClient.MySqlParameterCollection parameterCollection) [0x00056] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91937]   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor+<ExecuteReaderAsync>d__3.MoveNext () [0x0001d] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     91968] --- End of stack trace from previous location where exception was thrown ---
>  
> [     91984]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92000]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92015]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92031]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92062]   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92078]   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor+<ExecuteNonQueryAsync>d__1.MoveNext () [0x00094] in <5d2e43c2aa6f4da0bb43a6a12077ad51>:0 
>  
> [     92093] --- End of stack trace from previous location where exception was thrown ---
>  
> [     92109]   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92125]   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92140]   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92156]   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92171]   at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <0123fd5b1a1040fe9d70a7e0d4b28acb>:0 
>  
> [     92187]   at MySQLAsync.Operation`1+<ExecuteAsync>d__3[TResult].MoveNext () [0x00171] in <47c31aecc66e42ceb969da352f30fd4c>:0 
> [     92203] hitch warning: frame time of 631 milliseconds

you put a function in your parameters

Sorry what do you mean? I’m still relatively new at this. Cheers for the reply though!

Show the code that give this error, will tell you why then

I wish I knew, I’ve just setup mysql async and as soon as I log into the Server this pops up.

I’m off to bed, literally been at this for 11 hours - If you have any suggestions how to fix them please post and ill try in the morning. Thanks for replying already anyway! Your a champion.

New Expiremental API for mysql-async only available since build 363 of fivem, this API, will be the official and recommended way in future

https://github.com/brouznouf/fivem-mysql-async/tree/feature/promise-await

  • New api using coroutine to have a sync feeling while still being async : local result = MySQL.[execute|fetchScalar|fetchAll|insert](query, params) which is possible due to the Citizen.Await function which allow to wait in an asynchronous way promises.
    -- Not blocking the main thread, but block current execution context
    print(MySQL.fetchScalar('SELECT NOW() as world'))
  • All async functions now returns a promise which can be chained by using the next method
-- Promise api
local p = MySQL.Async.fetchScalar("SELECT 1")
p:next(function (result)
    print(result)

    return "test"
end):next(function (result)
    print(result)

    error 'An error'
end):next(nil, function(err)
    print(err)

    return ""
end)

-- Synchronisation
promise.all({
    MySQL.Async.execute('SELECT SLEEP(1)'),
    MySQL.Async.fetchScalar('SELECT "test"'),
}):next(function (results)
    print(json.encode(results))
end)

did you forget to call Await in the first sample or do you provide it in your wrapper? :stuck_out_tongue:

It’s provide in the wrapper :

  • MySQL.x : Async + Await (non blocking io)
  • MySQL.Async.x : Async (return promise)
  • MySQL.Sync.x : blocking api (faster in many cases as there is no async / thread overhead, but blocking)

im have one error fetchScalar with last build mysql-async

https://gyazo.com/8fa9ee7bf3fa159f209b6d5ad1be645c

cause this error is no result with request not return nil :confused:

Look at the changelog it was fixed in the last version, simply update your mod

1 Like

i’m have error after update with fetchScalar :confused:

[ERROR] [MySQL] An critical error happens on MySQL for query "SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe" {=}": Object reference not set to an instance of an object.   at MySQLAsync.FetchScalar.Reader (MySql.Data.MySqlClient.MySqlCommand command) [0x00007] in <4566d747b17a449f9901d640a8efcabd>:0
  at MySQLAsync.Operation`1[TResult].Execute (System.String query, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters, System.Boolean debug) [0x0004c] in <4566d747b17a449f9901d640a8efcabd>:0
[ERROR] [MySQL] An critical error happens on MySQL for query "SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe" {=}": Object reference not set to an instance of an object.   at MySQLAsync.FetchScalar.Reader (MySql.Data.MySqlClient.MySqlCommand command) [0x00007] in <4566d747b17a449f9901d640a8efcabd>:0
  at MySQLAsync.Operation`1[TResult].Execute (System.String query, System.Collections.Generic.IDictionary`2[TKey,TValue] parameters, System.Boolean debug) [0x0004c] in <4566d747b17a449f9901d640a8efcabd>:0
nil

my request

 MySQL.Sync.fetchScalar('SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe"',{}, function(rowsChanged)
      print(rowsChanged)
    end)

    local countPlayer = MySQL.Sync.fetchScalar('SELECT name FROM inventory WHERE owner = "license:e7d37d444efb3b10fa535b0dbbc7d2bc80f9c0fe"')

Having the same error too.