spyder 连接数据库 module 'pymysql
2018-07-20 本文已影响269人
哈斯勒
一、命令行安装
1.命令行输入

2. 检验是否安装成功

3. 连接数据库

以上的参数是必填的
host: 这个是ip地址,因为我这里是本地的,所以填127.0.0.1,也可以填localhost。
user:用户名,如果你也是本地的,就填root好了
passwd:这个是密码,填上你自己设的密码就可以了
db:这个是数据库名,我这里选的是news数据库
port:这个是端口,本地的一般都是3306
charset:这个是编码方式,要和你数据库的编码方式一致,要不会连接失败
二、 anaconda prompt 安装
1. 查看安装包列表

2. 安装pymsql

三、spyder 导入包时报错module 'pymysql' has no attribute 'connect'

https://stackoverflow.com/questions/25395648/connection-of-database-using-pymysql-in-python-3-x
提示:You've called some other module "pymysql". Look for a file named "pymysql.py" and rename it, and remove any associated .pyc file.
问题原因:
自己建的文件名用了pymysql


将这两个文件删除后,正常