Best MySQL Library?

I am currently using mysqloo for my MySQL needs. I don’t know of any other libraries that add the ability to integrate MySQL, but are there others?
I find mysqloo a bit… I don’t know the word… clumsy?

What extensions/modules/addons/libraries would you recommend for MySQL database integration?

Any helps is appreciated :smiley:

Shameless plug.

This seems more sleek. Thanks :smiley:

Any other ideas?

There’s tmysql4 which depending on the person you ask from is better or worse than mysqloo. Personally I don’t think it solves any API problems though; doing SQL queries on it is just as annoying/hard as is doing them on mysqloo.

Maybe it’d help if you told what you are actually looking for. Clumsy doesn’t really say anything.

By clumsy I mean over-complicated. To achieve even the simplest queries I need a pile of code. My sql needs are everything from advanced, so I just want something effective.

If you want anything threaded you’re gonna have to mess around with callbacks and it’s always going to end up “clumsy” I’m afraid.

[editline]17th March 2015[/editline]

Your choice is really tmysql vs mysqloo. You can make it slightly easier with a wrapper like FDB but it still uses one of tmysql/mysqloo under the hood.

mysqloo has some serious memory leak issues and is generally slower. pmysql may be handy.

I’ve never had any problems with it. And it will only cause you lag if you misuse it with calls to db:status().

I am on Linux though, might make a difference.

There is a memory leak in mysqloo 8(.1) which will make query data stay in memory until restart, it is caused by circular referencing and the reference counting algorithm used to delete the query objects.

Was this a problem when I was maintaining it or is it something just in the latest version?

[editline]17th March 2015[/editline]

I might take a look at it this weekend and see if I can work it out.

With the current mySQL binaries available, they exist more to provide an interface rather than an abstraction. You’re going to be better off making your own wrapper to work around one or both of them.

You’ll probably disagree with me but using SQLStr is not really great and you should always have the database engine always try and clarify what it thinks is a valid escape, especially given SQLStr is not exactly… fantastic.

I used to use each database engine’s own string escaping function, but it became kind of a mess. For example mysqloo requires you to have a valid database handle to do string escaping. That means FDB.ParseQuery() call would require you to pass the database handle for every query in case string escaping is required, which I think is an overkill.

I guess it’d be doable because no one’s supposed to be calling ParseQuery directly anyway, but it’d make it significantly harder to for example add unit testing.

tmysql4 now has the same behaviour as mysqloo.

I haven’t got the code in front of me at the moment, but you’re probably better off having some sort of default object for a ‘base’ connection, and if people want more connections, there’s a basic interface to create and add one and then they can pass it through varargs, or a table structure of sorts. It allows for unit testing and still keeps it ‘neat’.

I’m pretty sure you could use debug.getregistry or FindMetaTable to get the database object’s meta table and steal the escape function from it. Not something i’ve needed to do personally… but you could try it.

I have slightly modified https://github.com/wiox/gmsv_mysql and built a wrapper around it, this is now what my gamemode uses. It’s pretty good.