1

When I try reading the data from a mysql database using pandas.read_sql() it gives me the error:

UserWarning: pandas only supports SQLAlchemy connectable (engine/connection) or database string URI or sqlite3 DBAPI2 connection. Other DBAPI2 objects are not tested. Please consider using SQLAlchemy. df = pd.read_sql_query(q, mydb)

When printing the dataframe it will still contain the correct data however I am worried that this may cause issues in the future.

Is there anyway to overcome this? and is this error any significance.

I did read into SQLAlchemy engines but I am unsure of how to use an engine with mysql.connector and dont fully understand the purpose of the engine.

Shadow
  • 33,525
  • 10
  • 51
  • 64
Dinemite
  • 11
  • 1
  • It might not work if the query uses placeholders, since sqlite3 connector uses `?` for placeholders, but mysql connector uses `%s`. Yuo should be able to find a tutorial that shows how to use pd.read_sql with mysql. – Barmar Feb 16 '23 at 20:13
  • related: https://stackoverflow.com/q/71082494/2144390 – Gord Thompson Feb 16 '23 at 21:40

0 Answers0