MySQL is rarely queried in isolation; most applications reach it through a host
programming language and its MySQL driver. This chapter surveys the most common
ways to connect to and query a MySQL server from application code, and closes
with a brief comparison of MySQL against other popular SQL database engines.
PHP – the mysqli extension, in both
procedural and object-oriented styles, including its connection, query, and
information functions and the mysqli_result class.
Python – the mysql-connector-python
package: installing it, connecting, executing statements, and committing
changes.
Node.js – the mysql npm package:
installing it, creating a connection, connecting, and running queries.
SQL Engines – how MySQL compares to
PostgreSQL, Microsoft SQL Server, and Oracle Database.
An Alternative: JavaScript Inside the Server
Every environment above reaches MySQL from the outside, over a client
connection. As of MySQL 9.0, MySQL Enterprise Edition offers a different
option: JavaScript stored programs that run inside the server itself,
via the MySQL Multilingual Engine (MLE) (CREATE FUNCTION/
PROCEDURE ... LANGUAGE JAVASCRIPT). This is not a Community
Edition feature, and it does not replace PHP, Python, or Node.js as a client
environment – it is a way to move certain logic next to the data instead
of round-tripping it through the network. See
Compound Statements for the full
syntax and details.