Package for selecting and inserting into MariaDB database?

Sorry if this a really basic question, but I couldn’t filter useful information from the topics I have found here, I assume because of my inexperience in the subject. Since Monday, I’ve been trying to build and connect my code to a database for the first time, migrating from using files. My previous experience with databases has been contained to making a few simple queries.

Short version:
Is there a recommended package to use for connecting to a MariaDB database?

Long version:
I was trying to select a type of database to use in my project, so I initially went by what I saw at https://juliadatabases.org/ and by reading a bit and thought that using a MySQL db + MySQL.jl combo would yield the fastest and cleanest result. Today I spoke with a friend of mine with some experience who recommended me to look into MariaDB instead of MySQL for a variety of reasons, and particularly because I’m still in the early stages of this and it’s not “expensive” to redo the little I have done.
Assuming I am going to try using MariaDB instead of MySQL, I noticed that the MySQL.jl package uses a MariaDB connector. Can I use that package to connect to a MariaDB database and get the full features I would have available on a MySQL database?
I saw that the ODBC.jl package is more general because it relies on using drivers, so it can accommodate MariaDB, assuming I provide the driver file (would I have to package the driver file in my source code?). Alas, I am questioning jumping immediately to using ODBC.jl just because of the slower times I saw in the website mentioned above.

Probably @quinnj will know best.

MariaDB is more or less a fork of MySQL by the original MySQL developer, and can be considered the continuation of MySQL development. My guess is it should work fine with MySQL.jl especially if under the hood MySQL.jl is using mariadb libraries.

That’s exactly my intuition as well, @dlakelan, precisely because of the same reasons you mentioned. But I am in a tight timeframe and I am afraid of going that way just relying on plausibility and that is why I assumed it would be safer to ask here. For example, would I need to use some driver with the MySQL.jl package? If so, how? Since the connector seems to be based on MariaDB I would assume not, but just to be safe…

That is why I pinged @quinnj as he will know exactly how the situation looks since he implemented this.

Until MariaDB 5.5, MariaDB versions functioned as a “drop-in replacement” for the equivalent MySQL version, with some limitations. From MariaDB 10.0, it is usually still very easy to upgrade from MySQL.

I think your issue is does Julia need to support MariaDB? As long as they keep compatibility with the MySQL protocol, you need not worry. They did that (and likely will forever). EDIT:

MariaDB’s client protocol is binary compatible with MySQL’s client protocol.

Thanks @Palli. I’ll just wait to see if @quinnj is able to provide some insight as well, as @bkamins suggested.

EDIT: I wrote my post before your edit. I assume that means any mysql client connection protocol will work for mariadb.

Yes, the MySQL.jl package actually uses the mariadb C connector driver for database interactions. It should work just fine with either mysql or mariadb servers.

The ODBC.jl package should also work just fine. We’ve built the mariadb odbc driver into a JLL package, so you can use the MariaDB_Connector_ODBC_jll package and everything will be “bundled” for you automatically.

1 Like

All right, thanks everyone!

Just a heads up for anyone that might stumble upon this topic in the future.
MySQL.jl assumes the socket file in unix systems is produced in “/tmp/mysql.sock”.
For MariaDB, this is not the case, it’s (by default) “/var/run/mysqld/mysqld.sock”.
So you have to pass the keyword argument unix_socket=“/var/run/mysqld/mysqld.sock” into DBInterface.connect to make it connect.

2 Likes