Database Reference
In-Depth Information
Chapter 16. Application Programming
Interfaces
An API allows aprogramming language to interface easily with a computer software sys-
tem. The advantage of an API is that you can customize user interfaces to MySQL and
MariaDB to suit your needs. Huge websites use APIs to allow the public to interact with
their MySQL and MariaDB databases, without the user needing to know anything about the
databases they're using or SQL statements.
This chapter covers several APIs that may be used to interface with MySQL and MariaDB,
so that you may write customized applications to interface with databases. There are sec-
tions for the C API, the Perl DBI, the PHP API, the Connector/Python, and the Ruby API.
Many other programming languages have APIs for connecting to MySQL; these are just
some of the more popular ones. The section on each API and related libraries includes a ba-
sic tutorial on how to connect to MySQL and MariaDB, and how to query a database with
the API.
It's unlikely you will need to know more than one API. Instead, you may want to read the
section for the programming language you know and use. My preference is the Perl lan-
guage and the Perl DBI. It's most in line with natural languages such as English and Italian.
If you have no preference and would like to learn a MySQL API, though, the PHP API is
very popular and has many functions for interacting with MySQL. Plus, PHP is a fairly
easy language to learn and you can use snippets of code within web pages and content
management systems like Wordpress and Drupal.
It's beyond the scope of this topic to include a tutorial on any programming language. I as-
sume you can learn the basics of the language you choose among the many books and on-
line resources available. These examples use basic features of the languages to show you
how database access works.
Before skipping ahead to a section about a particular API, you should create a couple of
API user accounts that you may use in the examples and in the exercises. The exercises at
the end of the chapter are suited to whichever API you prefer, not to one in particular.
Search WWH ::




Custom Search