MYSQL, SQLALCHEMY, AND PANDAS
There are several ways to interact with a MySQL database, one of which is via SQLAlchemy. The Python code samples in subsequent sections rely on SQLAlchemy (which is briefly described in the next section) and Pandas.
What Is SQLAlchemy?
SQLAlchemy is an ORM (Object Relational Mapping), which serves as a “bridge” between Python code and a database. Install SQLAlchemy with this command:
pip3 install sqlalchemy
SQLAlchemy handles the task of converting Python function invocations into the appropriate SQL statements, as well as providing support for custom SQL statements. In addition, SQLAlchemy supports multiple databases, including MySQL, Oracle, PostgreSQL, and SQLite.
Read MySQL Data via SQLAlchemy
The previous section showed you how to install SQLAlchemy, and install Pandas (if you haven’t done so already) with this command:
pip3 install pandas
The Pandas functionality in the code samples involves the intuitively named read_sql...