0
我從我的Python腳本一個MySQL插入查詢,我遇到了以下錯誤 -如何聲明sql查詢在python
jobsummaryfile = '/home/abcd/projects/starling/daily_job_summary/'+ starling_date +'.tsv'
conn = connect_db()
cursor = conn.cursor()
cursor.execute("LOAD DATA LOCAL INFILE " + jobsummaryfile + " INTO TABLE daily_job_summary FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' (@col1,@col2,@col3,@col4) set ([email protected],[email protected],[email protected],[email protected])")
conn.close()
我得到的錯誤是 -
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '/home/abcd/projects/starling/daily_job_summary/2014_02_17.tsv I' at line 1")
它在最後拿起我,並導致它失敗。我如何擺脫這一點?
我解決了這個問題在我身邊...我需要一個更多的事情幫助...我想修改上面的查詢插入幾個變量從腳本到同一個表。 – rond