This is my first post! I started programming too, so please carry me!
I am trying to load a bunch of CSV files into a database so that I can later run various reports on the data. I started by creating several tables in mysql with the appropriate field names and data types for what will be loaded into the tables. I manipulate the file name (to parse the date to use as a field in my table) and clear the data using python.
So my problem right now (haha ...) is that I get this error message when I try to query "Insert Into" in mysql.
Traceback (most recent call last):
File "C:\Program Files\Python\load_domains2.py", line 80, in <module>
cur.execute(sql)
File "C:\Program Files\Python\lib\site-packages\MySQLdb\cursors.py", line 166, in execute
self.errorhandler(self, exc, value)
File "C:\Program Files\Python\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'a1200e.com' in 'field list'")
'a1200e.com' refers to a specific domain name that I insert in this column. My request is as follows:
sql="""INSERT INTO temporary_load
(domain_name, session_count, search_count, click_count,
revenue, revenue_per_min, cost_per_click, traffic_date)
VALUES (%s, %d, %d, %d, %d, %d, %d, %s)""" %(cell[0],
int(cell[1]),
int(cell[2].replace (",","")),
int(cell[3].replace(",","")),
float(cell[4].replace("$","")),
float(cell[5].replace("$","")),
float(cell[6].replace("$","")),
parsed_date)
cur.execute(sql)
I am completely new to this, so I am sure that my code is not at all effective, but I just wanted to lay out everything so that it was clear to me. I do not understand that I guaranteed that my data types are correctly defined in my table (corresponding to those specified in my query). Is there something I'm missing? I tried to do this for a while and don’t know what might be wrong: /
Thank you very much! Val