MySQL-SQLAlchemy-Pandas
MySQL-SQLAlchemy-Pandas copied to clipboard
Emulating MySQL codes by Pandas and SQLAlchemy
MySQL - SQLAlchemy - Pandas
These notebooks contain MySQL and Pandas code equivalents. Pandas uses the SQLAlchemy module to connect to MySQL databases and perform database operations.
These MySQL codes are mainly taken from mysqltutorial.org with minor modifications for easier comparison with Pandas codes.
I also provided some tips for configuring MySQL users and passwords.
Remember to load the Sample Database into MySQL Server before running the notebooks.
Happy coding!
Code example
MySQL Recursive CTE:

Emulated Pandas code:

Recently added 🆕 ✨
Table of Content
- ER Diagram and Tables of the Database
- Section 01 Querying Data
- 01 MySQL SELECT
- 02 MySQL SELECT statement without the FROM clause
- Section 02 Sorting Data
- 03 MySQL ORDER BY
- Section 03 Filtering Data
- 04 MySQL WHERE
- 05 MySQL DISTINCT
- 06 MySQL AND operator
- 07 MySQL OR operator
- 08 MySQL IN operator
- 09 MySQL NOT IN operator
- 10 MySQL BETWEEN operator
- 11 MySQL LIKE operator
- 12 MySQL LIMIT
- 13 MySQL IS NULL
- Section 04 Joining Tables
- 14 MySQL Alias
- 15 MySQL Joins
- 16 MySQL INNER JOIN
- 17 MySQL LEFT JOIN
- 18 MySQL RIGHT JOIN
- 19 MySQL CROSS JOIN
- 20 MySQL Self Join
- Section 05 Grouping Data
- 21 MySQL GROUP BY
- 22 MySQL HAVING
- 23 MySQL ROLLUP
- Section 06 Subqueries
- 24 MySQL Subquery
- 25 An Essential Guide to MySQL Derived Tables
- 26 MySQL EXISTS
- Section 07 Common Table Expressions
- 27 An Introduction to MySQL CTE
- 28 A Definitive Guide To MySQL Recursive CTE
- Section 08 Set Operators
- 29 MySQL UNION
- 30 Emulate the MINUS operator by JOIN or EXCEPT
- 31 MySQL INTERSECT
- Section 09 Modifying Data in MySQL
- 32 MySQL INSERT
- 33 MySQL INSERT Multiple Rows
- 34 MySQL INSERT INTO SELECT
- 35 MySQL INSERT ON DUPLICATE KEY UPDATE
- 36 MySQL INSERT IGNORE
- 37 MySQL UPDATE
- 38 MySQL UPDATE JOIN
- 39 MySQL DELETE
- 40 MySQL DELETE JOIN
- 41 MySQL ON DELETE CASCADE
- 42 MySQL REPLACE
- 43 MySQL PREPARE
Related resources
My Pandas codes are mainly inspired by this awesome Pandas Cookbook:
- Pandas 1.x Cookbook - 2nd Edition, see it's repository github
Contributing
If there are any problems or suggestions, feel free to suggest them on the issues page.