SQL. Databases - JulTob/Ada GitHub Wiki

Making Database Queries 16.14.1 mySQL

mySQL (pronounced "my ess que ell" ) is a free, high-performance database from T.c.X. It's available for a number of platform, including Linux. The mySQL home page is http://www.mysql.org.

mySQL comes with a C library called "mysqlclient". If an Ada program links in this library with "-lmysqlclient", it can access mySQL databases. You issue commands to the database called queries using the database language SQL (pronounced "sequel").

Connecting to a mySQL database is a six step process:

Open a new connect using mysql_init.
Login using mysql_real_connect.
Perform database queries with mysql_query or mysql_real_query. real_query allows binary data in the query.
Retrieve the results using mysql_store_result or mysql_use_result.
Free any memory using mysql_free_result.
Close your connection with mysql_close.

Usually, a null point or non-zero integer result indicates an error. mysql_errono returns the error.

Complete documentation is available from the mySQL web site.