Using sqlalchemy
suggest changeTo use sqlalchemy for database:
from sqlalchemy import create_engine
from sqlalchemy.engine.url import URL
url = URL(drivername='mysql',
username='user',
password='passwd',
host='host',
database='db')
engine = create_engine(url) # sqlalchemy engine
Now this engine can be used, for example with pandas, to fetch dataframes directly from MySQL. URL(...) is the older constructor. Current SQLAlchemy uses URL.create(...). SQLAlchemy and pandas are not installed here, so this was not run.
import pandas as pd
con = engine.connect()
dataframe = pd.read_sql(sql=query, con=con)
query is not defined on this page.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents