SQL using SQLAlchemy
The pandas library provides robust capabilities for interacting with SQL databases, allowing you to perform data analysis directly on data stored in relational databases.
There are, of course, countless databases that exist (and more are coming!), each with its own features, authentication schemes, dialects, and quirks. To interact with them, pandas relies on another great Python library, SQLAlchemy, which at its core acts as a bridge between Python and the database world. In theory, pandas can work with any database that SQLAlchemy can connect to.
To get started, you should first install SQLAlchemy into your environment:
python -m pip install sqlalchemy
SQLAlchemy supports all major databases, like MySQL, PostgreSQL, MS SQL Server, etc., but setting up and properly configuring those databases is an effort in its own right, which cannot be covered within the scope of this book. To make things as simple as possible, we will focus on using SQLite...