I am trying to load data into a MySQL table with the following Python script:
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 jobname=@col1, queue=@col2, maphours=@col3, reducehours=@col4, date=" + date +
", pipeline=" + pipeline_name + ", grid=" + grid
)
I am getting the following error:
_mysql_exceptions.OperationalError: (1054, "Unknown column 'galaxy' in 'field list'")
I know it is a quotes issue while passing the query, but I am having a hard time trying to figure it out. Can someone please suggest where am I making a mistake?
This is the query I want to execute:
LOAD DATA LOCAL INFILE 'file.tsv'
INTO TABLE daily_job_summary
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
(@col1, @col2, @col3, @col4)
set jobname=@col1, queue=@col2, maphours=@col3, reducehours=@col4,
date=2014-01-05, pipeline='abcd', grid='AB'
This is my table structure:
| id | int(11) | NO | PRI | NULL | auto_increment |
| date | date | YES | | NULL | |
| pipeline | varchar(12) | YES | | NULL | |
| grid | varchar(2) | YES | | NULL | |
| jobname | varchar(255) | YES | | NULL | |
| maphours | int(11) | YES | | NULL | |
| reducehours | int(11) | YES | | NULL | |
| queue | varchar(60) | YES | | NULL | |
pipeline_namegridtoo."pipeline='"+pipeline_name+"', grid='"+grid+"'"