API C MySQL

Per accedere a MySQL da c si possono utilizzare le API C distribuite insieme a MySQL. Le API sono già disponibili con MySQL e quindi non è necessario andarle a cercare o installarle.
Le API C sono incluse nella libreria mysqlclient e consentono ai programmi C di accedere al database. La libreria mysqlclient contiene dei tipi di dato predefiniti e delle procedure che consentono l’interazione tra il client, scritto in c, ed il server MySQL. Le principali funzioni della libreria sono le seguenti

Funzioni
Metodo Descrizione
mysql_affected_rows() Returns the number of rows changed/deleted/inserted by the last UPDATE, DELETE, or INSERT query.
mysql_autocommit() Toggles autocommit mode on/off.
mysql_close() Closes a server connection.
mysql_commit() Commits the transaction.
mysql_connect() Connects to a MySQL server. This function is deprecated; use mysql_real_connect() instead.
mysql_create_db() Creates a database. This function is deprecated; use the SQL statement CREATE DATABASE instead.
mysql_data_seek() Seeks to an arbitrary row number in a query result set.
mysql_drop_db() Drops a database. This function is deprecated; use the SQL statement DROP DATABASE instead.
mysql_eof() Determines whether the last row of a result set has been read. This function is deprecated; mysql_errno() or mysql_error() may be used instead.
mysql_errno() Returns the error number for the most recently invoked MySQL function.
mysql_error() Returns the error message for the most recently invoked MySQL function.
mysql_fetch_field() Returns the type of the next table field.
mysql_fetch_field_direct() Returns the type of a table field, given a field number.
mysql_fetch_fields() Returns an array of all field structures.
mysql_fetch_lengths() Returns the lengths of all columns in the current row.
mysql_fetch_row() Fetches the next row from the result set.
mysql_field_seek() Puts the column cursor on a specified column.
mysql_field_count() Returns the number of result columns for the most recent statement.
mysql_field_tell() Returns the position of the field cursor used for the last mysql_fetch_field().
mysql_free_result() Frees memory used by a result set.
mysql_get_client_info() Returns client version information as a string.
mysql_get_host_info() Returns a string describing the connection.
mysql_get_server_version() Returns version number of server as an integer.
mysql_get_proto_info() Returns the protocol version used by the connection.
mysql_get_server_info() Returns the server version number.
mysql_info() Returns information about the most recently executed query.
mysql_init() Gets or initializes a MYSQL structure.
mysql_kill() Kills a given thread.
mysql_library_end() Finalize MySQL C API library.
mysql_library_init() Initialize MySQL C API library.
mysql_more_results() Checks whether any more results exist.
mysql_next_result() Returns/initiates the next result in multiple-statement executions.
mysql_num_fields() Returns the number of columns in a result set.
mysql_num_rows() Returns the number of rows in a result set.
mysql_options() Sets connect options for mysql_connect().
mysql_query() Executes an SQL query specified as a null-terminated string.
mysql_real_query() Executes an SQL query specified as a counted string.
mysql_real_connect() Connects to a MySQL server.
mysql_rollback() Rolls back the transaction.
mysql_row_seek() Seeks to a row offset in a result set, using value returned from mysql_row_tell().
mysql_row_tell() Returns the row cursor position.
mysql_select_db() Selects a database.
mysql_shutdown() Shuts down the database server.
mysql_stat() Returns the server status as a string.
mysql_store_result() Retrieves a complete result set to the client.
mysql_use_result() Initiates a row-by-row result set retrieval.