-1
我正在嘗試使用數字數據var'y'的excel數據,並將其放入我的SQL列'Close'中。TypeError:'str'對象不可調用
import xlrd
import MySQLdb
#get excel data
file_location = "C:/Users/.../.../...xls"
workbook = xlrd.open_workbook(file_location)
sheet = workbook.sheet_by_name("Sheet1.1")
y = sheet.col_values(3, start_rowx=2, end_rowx=31)
#open connection SQL
db=MySQLdb.connect(host = "host",
user = "user",
passwd = "passwd",
db = "test")
cursor = db.cursor()
cursor.execute("""UPDATE uk SET Close.....""")
db.commit()
但是我不確定寫什麼來插入它。
cursor.execute("""UPDATE uk SET Close = %s""", (y,))
給出了錯誤:
OperationalError: (1241, 'Operand should contain 1 column(s)')
感謝您的幫助,也可以提供方向。