import pandas as pd
from sqlalchemy import create_engine# 初始化数据库连接
engine = create_engine('mysql+pymysql://root:556@localhost:3306/仓库')sql_cha='SELECT * FROM `库房`'
print(sql_cha)
df_read = pd.read_sql_query(sql_cha, engine);
print(df_read);
VS连接mysql如上,但是报错,缺库,于是如下操作解决!!
1.cmd
2.切换到python安装目录的Python-Lib-site-packages目录下面
3.输入命令pip install pandas执行安装。
成功!!
VS的python环境也有
顺便也导入
pip install flask_sqlalchemy
导入pip install pymysql
Python 连接 MySQL 数据库 - 知乎 (zhihu.com)