MySQL C API


From Docunext Technology Wiki

Jump to: navigation, search

I want to learn how to write a MySQL client in C.

First Try

It doesn't do anything:

#include <mysql/mysql.h>
int main()
{
   MYSQL mysql;
   mysql_init(&mysql);
   mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"blah");
}

But it compiles:

gcc mysql_client.c -o mysql_client -I/usr/include -L/usr/lib/mysql -lmysqlclient


Actual Goal

I'd really like to create a dbslayer-like module for NGINX. Instead of taking queries as part of the URL, it would match locations to prepared queries. Considering my limited experience with C, it would take awhile to create.

Painting with a broad stroke, I'd patch something together from pieces of the mysql client (which can output XML), DBSlayer, and an existing NGINX module.

External Links

Personal tools