From Fedora Project Wiki

Revision as of 15:41, 4 March 2019 by Mschorm (talk | contribs) (Add tiny tested example)

Article about the mariadb-connector-c package

Connector releases

mariadb-connector-c 3.0 - current (F28, Rawhide)

In Fedora<=26 the connector does not work. It is built on top of old mysql client library, which lead to lot of issues.
In Fedora 27 the connector package is empty and requires mariadb-devel and mariadb-libs, which contains all of the files that would be in the connector.

At the upstream, the connector-c is developed as a git submodule of mariadb server.
That means every new release of mariadb has the latest connector c code inside.

Developement of 3rd software

All packages that required mysql-devel, mariadb-devel or community-mysql-devel should now require mariadb-connector-c-devel instead.
(#1486480 and proposal)

Only software that needs to develop against the server (for example building custom server plugins or application with embedded database) should use mariadb-devel.

By this approach, client and server parts were successfuly divided.

Usage examples

I would recommend this website, often referenced on the internet, as a good example and tutorial for writing C code with this connector.
http://zetcode.com/db/mysqlc/

It is originally written for mysql connector c, but they are more or less compatible.

You can also try following code:

#include <stdio.h>
#include <mysql.h>

void main()
{
  printf("MySQL client version: %s\n", mysql_get_client_info());
  return;
}

Compiled with:

gcc mariadb_code.c -o mariadb_program `mariadb_config --cflags --libs`

The invocation of mariadb_config --cflags will set the correct path to search header files in.

Notes

Upstream infromation
API reference