📜  如何在python代码示例中读取mysql表

📅  最后修改于: 2022-03-11 14:47:18.894000             🧑  作者: Mango

代码示例2
import pandas as pd
import sqlalchemy

# make sure you have installed both mysql & pymysql

                                                    # root:root is my username and password/default
engine = sqlalchemy.create_engine("mysql+pymysql://root:root@localhost/database name", pool_pre_ping=True)
# then specify the name of the table in the database
df = pd.read_sql_table('table name', engine)
print(df)