markvanten
St.Mark
2021-01-20 22:12

用pythom、mypysql链接数据库链接不成功求大佬指点

  • python
  • mysql
  • sql
import pymysql
db = pymysql.connect('localhost','root','mkfmkf','mrsoft')
cursor = db.cursor()
cursor.execute('SELECT VERSION')
date = cursor.fetchone()
print('Date:%s'%date)
db.close




Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
===================== RESTART: D:\Python\数据库练习\chage.py =====================
Traceback (most recent call last):
  File "D:\Python\数据库练习\chage.py", line 2, in <module>
    db = pymysql.connect('localhost','root','mkfmkf','mrsoft')
TypeError: __init__() takes 1 positional argument but 5 were given
>>> 

 

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答