Link to home
Start Free TrialLog in
Avatar of Dolamite Jenkins
Dolamite JenkinsFlag for United States of America

asked on

OperationalError: (1054, "Unknown column 'Age' in 'field list'")

I dont understand why I am getting this error ... you can see in the database info section that I  have 'Age' ... Im assuming mysql has some syntax and I'm getting it wrong ... why am I getting this error and why ?


Traceback (most recent call last):
  File "C:\Python26\lib\threading.py", line 532, in __bootstrap_inner
    self.run()
  File "C:\Python26\sign\OCTOBER29_mysqldevlopment.py", line 6880, in run
    cursor.execute("INSERT INTO newtable (Active_Incident_number, Age,Gender,Zip,Ailment,Treatment,Initial_contact,Hospital,Destination,Inservice,Sys,Dia,Pulse,Resp,Weather, Temp,Humid,Wind,TimeStamp) VALUES ( %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s,%s,%s, %s,%s, %s)",(Actual_Incident_number, Age,Gender,Zip,Ailment,Treatment,Initial_contact,Hospital,Destination,Inservice,Sys,Dia,Pulse,Resp,Weather, Temp,Humid,Wind,TimeStamp));
  File "C:\Python26\lib\site-packages\MySQLdb\cursors.py", line 173, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'Age' in 'field list'")

Open in new window


Info about my databases and tables

my databases

('transferdb',)

my tables

('newtable',)

 info about table newtable
('Active_Incident_number', 'int(11)', 'YES', '', None, '')
(' Age', 'int(11)', 'YES', '', None, '')
('Gender', 'varchar(20)', 'YES', '', None, '')
('Zip', 'int(11)', 'YES', '', None, '')
('Ailment', 'varchar(20)', 'YES', '', None, '')
('Treatment', 'varchar(20)', 'YES', '', None, '')
('Initial_contact', 'varchar(20)', 'YES', '', None, '')
('Hospital', 'varchar(20)', 'YES', '', None, '')
('Destination', 'varchar(20)', 'YES', '', None, '')
('Inservice', 'varchar(20)', 'YES', '', None, '')
('Sys', 'int(11)', 'YES', '', None, '')
('Dia', 'int(11)', 'YES', '', None, '')
('Pulse', 'int(11)', 'YES', '', None, '')
('Resp', 'int(11)', 'YES', '', None, '')
('Weather', 'varchar(20)', 'YES', '', None, '')
('Temp', 'varchar(20)', 'YES', '', None, '')
('Humid', 'varchar(20)', 'YES', '', None, '')
('Wind', 'varchar(20)', 'YES', '', None, '')
('TimeStamp', 'varchar(20)', 'YES', '', None, '')

Open in new window



#get transferred information
	    conn = lite.connect("PermPatRecord.sqlite")
	    c = conn.cursor()
	    c.execute('select * from ptrecords')
	    for rows in c:
		Actual_Incident_number=+rows[0]		
		Incident_number = rows[1]
		Age= rows[4]
		Gender = rows[5]
		Zip = rows[8]
		Ailment = rows[10]
		Treatment =rows[11]
		Initial_contact= rows[13]
		Hospital = rows[14]
		Inservice= rows[16]
		Destination= rows[15]
		Sys =rows[19]
		Dia=rows[20]
		Pulse=rows[21]
		Resp=rows[22]
		Weather=rows[23]
		Temp=rows[24]
		Humid=rows[25]
		Wind=rows[26]
		TimeStamp=rows[27]
		db = MySQLdb.connect(host="localhost", user="root", passwd="",db="transferdb")
		cursor = db.cursor()
		cursor.execute("INSERT INTO newtable (Active_Incident_number, Age,Gender,Zip,Ailment,Treatment,Initial_contact,Hospital,Destination,Inservice,Sys,Dia,Pulse,Resp,Weather, Temp,Humid,Wind,TimeStamp) VALUES ( %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s,%s, %s, %s,%s,%s, %s,%s, %s)",(Actual_Incident_number, Age,Gender,Zip,Ailment,Treatment,Initial_contact,Hospital,Destination,Inservice,Sys,Dia,Pulse,Resp,Weather, Temp,Humid,Wind,TimeStamp));
		
		db.commit()
		cursor.close()
		db.close()
    
    
		   
	    conn.commit()
	    cur.close()
	    conn.close()

Open in new window

Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

No, you don't have "Age', you have ' Age' with a space in front of it.  Yes, that does make a difference.
Avatar of Dolamite Jenkins

ASKER

Can you answer another question ?

OperationalError: (1366, "Incorrect integer value: '' for column 'Zip' at row 1")

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much this is my first go around with mysql server ... I was told it was very similar to sqlite ... not true but I finally got it working .... thanks
You're welcome, glad to help.