[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • Last Modified:

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

0
dolamitejenkins
Asked:
dolamitejenkins
  • 3
  • 2
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
No, you don't have "Age', you have ' Age' with a space in front of it.  Yes, that does make a difference.
0
 
dolamitejenkinsAuthor Commented:
Can you answer another question ?

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

Open in new window

0
 
Dave BaldwinFixer of ProblemsCommented:
It looks like your "cursor.execute()" statement is trying to put strings into integers or the value for Zip is simply wrong, maybe a letter in it.  Generally speaking, a Zip and Zip+4 fields should be a character or text type because, although it is composed of numbers, it is used as a name and leading zeros need to be preserved.  A numeric field will strip leading zeros.
0
 
dolamitejenkinsAuthor Commented:
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
0
 
Dave BaldwinFixer of ProblemsCommented:
You're welcome, glad to help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now