您好,我想使用“加载数据 Infile”将数据从 excel 文件或 .txt 导入数据库,但我的文件的路径包含“\”,Mysql 不接受女巫
要清楚这是我的 Python 代码:
def parcourir(self):
fi=QFileDialog.getOpenFileName(self)
self.Pathfile.setText(fi)
def chargeFile(self):
try:
fiche=open(self.Pathfile.text(),'r')
except IOError :
QtGui.QMessageBox.warning(self,"erreur","fichier nontrouvé")
connection = MySQLdb.connect (host = "localhost", user = "root", passwd = "", db = "lexique")
cursor = connection.cursor()
query="LOAD DATA INFILE 'self.Pathfile.text()' INTO TABLE tbl_lexique FIELDS TERMINATED BY ',' ENCLOSED BY '\"'LINES TERMINATED BY '\n'"
cursor.execute( query )
connection.commit()
...................