import MySQLdb
db = MySQLdb.connect(host="?",
user="root",
passwd="?",
db="test")
cursor = db.cursor()
file = open('...../EM.txt', 'r')
file_content = file.read()
file.close()
query = "INSERT INTO EM VALUES (%s,%s,%s,%s,%s,%s)"
cursor.execute(query, (file_content,))
db.commit()
db.close()
我試着從代碼中讀取文本文件並插入到EM表中......任何一個人都可以幫我做這項工作?從文本文件插入到mysql表中使用python
您遇到什麼問題? – Tgsmith61591