Iām so gonna use this in a script cuz c# rocks for coding
Updated
Changes:
- Added Multithreading. This speeds up using many database querys quite a bit.
- Fixed the missing handling of Parameters by QueryScalar[Async].
- Added support for using Convars instead of definiting the server connection by the
settings.xml - Added an optional Callback to :Insert
Installed this on my servers to compare performance with mysql-async and iāll probably keep your resource, it works great! nice job.
Updated
Changes:
- Insert now has another optional parameter, to indicate if it should return the last inserted id by the statement. The id needs to be an auto incrementing value.
- Added an optional console variable / convar
mysql_thread_limit, which can be set in the server.cfg if you want to limit or control multithreading better. - Fixed an bug where QueryScalar[Async] would crash the resource when it returned null, as the server tries to unwrap nothing. Do not use dynamic and send null with it folks.
- Added Transactions.
- Changed so Debug mode would show querys stringified. Not correctly, but probably enough to debug your queries.
- Jumped the Version, because I am almost out of ideas to add.
Then how do you use it? You only show the exports?
https://github.com/GHMatti/FiveM-MySQL/blob/master/MySQLTest/cs/MySQLTest.cs
Should be indicative enough on how to do it. The exports are only the neat wrappers for lua.
There is a compiled library in the release section which you can reference. 
editted the mainpost to clarify.
Thank you! Really helpful now. 
One more question for you, do functions automatically execute as async or is there a function I dont see for async? None of the functions related to GHMatti.Mysql.Mysql have anything that say async
Edit: I see that you are using a Task function in the example, is that what makes it async?
Using the task functions on different threads makes it async (not really in the truest sense but async for endusers). Just using the task function one the same thread would not make it async (as they are FIFO).
The async calls have the performance issue, due to the IOAwaiter from the CLR, which is in sync with the server thread (which forces it to sleep every call for 40-50ms) ā so just awaiting one async call will create the possibility for it to lag. So to make it async in the simplest case, you put them on different threads, so that they execute independently from each other; so they are async for the server thread. Ideally though I will get them even async on their respective threads, but that requires the use of the Async functions which are due to CLR/FXServer slightly broken.
I can and will try to use the async functions at some point (again), but I fear that many of them are not usable due to them awaiting something where I do not have control over the awaiter; also I will very need to change the FIFO behaviour. The sync functions from the MySqlConnector are themselves just the async functions synchronized.
edit: Alternatively I can rewrite the async functions with my taskscheduler, which should work, but is definately not preferred. On a four core, on default settings it would look like this:
Thread 1|----Query 1----|-------Query 4-------|
Thread 2-|------Query 2------|-------Query 6-------|
Thread 3--|----Query 3----|-----Query 5-----|----Query 7----|
S Thread|---------------1-3--2--------------5-4----6--------7
If you merge that back to the super thread it is async, not perfectly, but as much async as I could get them to be with a very basic class. Also none of them are blocking the server thread, so you can go as crazy as you want.
Thank you for this. I just finished putting it in dev, once it goes on the live servers, Iāll be sure to comeback and provide more feedback. I was always noticing some frame lag on the server when we did data syncs using mysql-async
Great work, good release. Once mysql-async starts hanging/timing out at higher player counts they will be running to you 
Updated
Changes:
- Updated MySqlConnector to 0.36.1
- Changed the License to AGPL (if you change something and use it/distribute the end version, share it)
- Added a Drag and Drop Replacer for mysql-async, which is not recommended to use. ReadMe
Seems OK, but could you create a wrapper for MySQL-Async API compatibility?
It would be much easier for people to start using it for an already existing code.
(I will do it first:D )
Hasnt he already?
20
Indeed I have. As @Nick78111 said. Follow the readme. Unless you do some really odd stuff in your code. It replaces it seamlessly or you use the .insert function and do something with the Id returned.
Well, unfortunately, itās impossible to use it as Git submodule, because you use one big repo for multiple projects.
we tend to git clone git@host:repo [category], but thatās of course assuming thereās a resource folder in the root of the output repo.
currently thereās no way to automatically build projects requiring building in the server anyway, and Iām not sure if this repo includes binaries at all (which would be against best practices)
- The main project compiles to the resource folder in the bin folder.
- Then there is a C# Library, because the server freezes if you link to a BaseScript.dll.
- A tiny testing example for both Lua and using the C# Library.
- And the replacement resource.
There is a reason why I linked the releases in the first post on the forums, because that is what end users who do not want to manipulate the code should use in the first place.
The most I would do is to put them on seperate branches, and that requires me to maintain then 3 additional branches, where the C# Library and not the Lua implementation represents the master, logically.
And yes, there will never be binaries in there.
Hi @zr0iq
I have a question about returned value. Iām using your script ( and I have seen clearly the difference between yours and mysql-async) and I found something interesting. I have read your post but I didnāt find the answer. Iām developing in Lua if youāre asking the question. When I use exports['GHMattiMySQL']:QueryScalar on a null value, I have a table with null value in return value. Is this normal ? ( I adapted my code to your implementation to avoid any problems and it works fine)
Probably because of some oversight on my end. Time to squash a bug. I replicated that behaviour. Thanks a lot. Shouldnāt be longer than 4h needed for the fix to be online.