10

新手求教pycharm python代码连接mysql报错?

Navicat和pycharm的DB Browser 可以打开这个数据库。

import pymysql
db = pymysql.connect(host=“localhost”,port=3306,user=“root”,password=“root”,database=“csdn_crawler”)
cursor = db.cursor()
cursor.execute(“select * from article”)
result = cursor.fetchone()
print(result)
运行后报错:Traceback (most recent call last):
File “D:\python_work\python爬虫\四、数据存储\04MySQL数据库操作\01-连数据库.py”, line 1, in
import pymysql
File “D:\python_work\venv\lib\site-packages\pymysql_init_.py”, line 28, in
from .converters import escape_dict, escape_sequence, escape_string
File “D:\python_work\venv\lib\site-packages\pymysql\converters.py”, line 4, in
from decimal import Decimal
File “D:\Python\lib\decimal.py”, line 3, in
from _decimal import *
AttributeError: module ‘numbers’ has no attribute ‘Number’
The first three itrms in the list are:
512
729
1000

查看全部
tzxiaochao
tzxiaochao
2020/11/29 21:33
  • python
  • mysql
  • 点赞
  • 收藏
  • 回答
    私信

3个回复