【发布时间】:2017-12-08 21:42:06
【问题描述】:
我想检查我是否已设法以正确的方式将我的 csv 文件导入 MySQL db。我的代码
import MySQLdb
mydb = MySQLdb.connect(host = 'localhost',user = 'milenko',passwd = 'nuklear',db = 'mm')
cur = mydb.cursor()
command = cur.execute('SELECT * FROM jul')
results = command.fetchall()
print (results)
但我得到了这个
File "b12.py", line 6, in <module>
results = command.fetchall()
AttributeError: 'int' object has no attribute 'fetchall'
我看过以前的 SO 帖子,人们声称 number 对象没有 fetcall 对象。我从 Albert Lukaszewski 的 Python for MySQL 复制了这段代码。 如何一次性拉取数据库内容?
【问题讨论】:
标签: python mysql mysql-python