MySQL Async Library
You can find it here with all the instructions : https://github.com/brouznouf/fivem-mysql-async
This lib does not replace EssentialMode, it offers however async methods and compatible API for people only needing Essential Mode for MySQL
The current API should be stable, but it may change before a first stable release.
Feel free to raise Issues/Pull request on Github
- Async method for mysql by using a callback
- Sync method also available but not recommended
If for some reason you still want the C# Version it can be downloaded from https://github.com/brouznouf/fivem-mysql-async/tree/2.0
- Fixes mysql-async not parsing the BIT column, which would return a buffer otherwise.
- Added a version to the resource.lua so scripts can ask for the version by querying the metadata.
- Refactor to use Promises in preparation for adding transactions.
- Make the error on the missing connection string clearer.
- Added a warning on queries that take more than 500ms. Time can be controlled by setting
set mysql_slow_query_warning <time-in-ms>
set mysql_slow_query_warning 50
to print all queries that take more than one server-tick to complete. Setting it to 0 should disable the slow query warnings.
- 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
when the second query is the select (hence the 2 in the result).
- Debug print shows now the resource requesting the mysql-query.
- DateTime, DateTime2, Timestamp, Timestamp2, Date, Year should now behave properly. Is cast to ms, not to seconds.
- Time, Time2 are currently not parsed.
- It should be STABLE now on Linux without any leakage. Many thanks to @Doacola for running tests showing stable ram.
- Fixes the issue above (datetime, datetime2, timestamp2 is now cast to seconds)
- Fixed that dates were not returned as in 2.x. Timestamps are now returned in seconds. DateTime is tableified.
- For this fix to work you must not have dateStrings=true on your connection string.
- I probably introduced some bugs with this.
- Some rough progress was made with getting 3.x to run stable on linux.
- Allow multiple statements per query string on the legacy connection string
- Support bignumbers by default on the legacy connection string
- Parse both types of connection strings into options. No need to change it anymore.
- Fixed an issue that
MySQL.readymight not trigger on resource restart.
onMySQLReadywill still trigger only once, but MySQL.ready should work now properly.
- Migrated entire library to node.js
Breaking : The console variable
mysql_connection_stringneeds to be formated now like
mysql://username:password@host/database?dateStrings=trueadditional options can be chained like in urls, first with ? then with &. The options can be gotten from https://github.com/mysqljs/mysql#connection-options
- Breaking : Transactions are not included in this release candidate.
- Threaded options are no longer needed and will be removed as of 3.1.0
Change Log Version 2.X
- Added default options for connection strings and mysql_debug, so it should not error anymore, hopefully.
- SslMode is set to none by default contributed by @Syntasu
- Updated MySqlConnector to a Custom 0.38.0 Release; This fixes the sessions leaking on heavy contention.
- Updated MySqlConnector to a Custom 0.37.1 Release. I am not sure if I lost performance on Async queries somewhere along the way from 0.26/2.0.2; can someone compare?
- Added Threaded operations. They work the same way as sync calls, but are slower as they are not executed on the server thread. You call them by using
MySQL.Threaded.execute/insert/fetchAll/fetchScalar. If you are experiencing timeouts (replace some async queries with them). If you are experiencing hitches, replace some sync queries with them.
- Added Transactions; they do not have a Threaded option yet.
- Updated MySqlConnector to a Custom 0.36.1 Release (Differences will be on my MySqlConnector branch once I reach the up to date version 0.37.0). This should improve performance, reduce CPU load, and contains tons of bugfixes.
- Updated MySqlConnector to 0.28.2 (the last version to actually work with mysql-async) Thanks to @IceHax testing it once.
- Fix receiveing null result on fetch scalar
- Remove native call on exception to avoid fatal error
- Better logging, split time between connection / query / reading
- Add mysql_debug config for activation / deactiving log of queries
- Fix bug when returning null on fetchScalar
- Add “MySQL.ready” function, use this function insted of the onMySQLReady event
- Update underlying lib
- Fix file name for linux
- Readd pooling
- Fix hard bug with fields and value being null cause of using IsDbNullAsync
- Better exception message
- Better error detection
- Now show parameters in the log
Previous not for Beta 3:
It is now FULLY Async, before only the query execution was async, now it’s everything when using Async functions (Opening connecting, Query Execution and Result reading are async)
2.0.0-beta3 - Don’t use it it’s broken !
- Complete rewrite, should be more stable and faster for async version
- Add mysql_debug convar (default to false) true = print query statements
- Add insert methods which allow to execute a query and return the last insert id from the database
- Add a vstudio project, to give more trust about what is done and allow better contribution
- Update to last version of the underlying lib
- Fix a memory leak
- Upgrade underlying mysql lib to fix some bugs (0.19.5 to 0.23.0)
- Small but existing BC Break on the new API (read the upgrade guide)
- FXServer Only
- No more support for essential mode API (you should update to the new API before upgrading to 2.0)
Change Log Version 1.X
- No changes since 0.2.2, it just stable enough to release it under a stable version
- Close connection before calling user callback, so in case of error connection is still properly closed
- Fix bad transformations of fields, .NET object were present in result which used in TriggerEvent would faild as MessagePack don’t know how to transform it
- Add a optional script to clear connections every 10sec
- Fix bug of not closing connections, due to this pooling has been desactivated, will reactivate once i have proper time to debug this.
- Remove coroutine support as it was leaking thread due to the way of using it
- Stabilize connections on mysql (correctly open / close)
- Fix many bugs about specific parameters and null value on a Select queries
- Add query log (with execution time of the query)