Retrieve MySQL/MariaDB data with Python

A while ago I had some issues retrieving data from MySQL using Python, as my Python was more up-to-date than the official bindings. A few days ago I found a nice GIST (https://gist.github.com/stefanthoss/364b2a99521d5bb76d51) that uses pymysql:

import pandas as pd
import pymysql
from sqlalchemy import create_engine
 
engine = create_engine('mysql+pymysql://<user>:<password>@<host>[:<port>]/<dbname>')
df = pd.read_sql_query('SELECT * FROM table', engine)
df.head()

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website