I am trying to create a SQL string from a python script.
this is the code:
sql_query = ('insert into ithelpdesk '
'(id,display_id,subject,description,priority,status,requester_name,source,responder_id,due_by,updated_at,frDueBy,ticket_type,created_at)'
' values ('
'"' + str(data['id']) + '",'
'"' + str(data['display_id']) + '",'
'"' + data['subject'] + '",'
'"' + data['description'] + '",'
'"' + str(data['priority']) + '",'
'"' + str(data['status']) + '",'
'"' + data['requester_name'] + '",'
'"' + str(data['source']) + '",'
'"' + str(data['responder_id']) + '",'
'"' + str(data['due_by']) + '",'
'"' + str(data['updated_at']) + '",'
'"' + str(data['frDueBy']) + '",'
'"' + data['ticket_type'] + '",'
'"' + str(data['created_at']) + '"'
')')
when I run I am getting this traceback message:
Traceback (most recent call last):
File "c:\users\swatson\dropbox\source files\winpython\dash\newTickets.py", line 198, in <module>
main()
File "c:\users\swatson\dropbox\source files\winpython\dash\newTickets.py", line 159, in main
addNew(n)
File "c:\users\swatson\dropbox\source files\winpython\dash\newTickets.py", line 65, in addNew
'"' + str(data['created_at']) + '"'
TypeError: coercing to Unicode: need string or buffer, NoneType found
Now I know for a fact (by doing a printstr(data['created_at'])) that there is a value at data['created_at'], and I also know that is is the same value as with data['updated_at'] so I am at a loss as to how to resolve this?