This chapter discusses how to use MySQL from within the context of a general-purpose programming language. It covers basic application programming interface (API) operations that are fundamental to and form the basis for the programming recipes developed in later chapters. These operations include connecting to the MySQL server, executing statements, and retrieving the results.
MySQL-based client programs can be written using many languages. This book covers the languages and interfaces shown in the following table (for information on obtaining the interface software, see the Preface):
MySQL client APIs provide these capabilities, each covered in a section of this chapter:
Every program that uses MySQL must first establish a connection to the server. Most programs also select a default database, and well-behaved MySQL programs close the connection to the server when they’re done with it.
Any database operation can fail. If you should know how to find out when that occurs and why, you can take appropriate action such as terminating the program or informing the user of the problem.
The point of connecting to a database server is to execute SQL statements. Each API provides at least one way to do this, as well as methods ...