Reputation: 5424
I have a scenario in which i have to store python list in database via python script. i have seen lot of solution like converting it into tuple or removing quotes around a string. but it want to store it into database in python list format.
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
and my query is
sql_test = "UPDATE log_messages SET unique_arguments = %s , sent_to = %s where log_id = %s " % (unique_arguments_list,email_send_to,str(log_id))
and getting this error
syntax error at or near "["
LINE 1: UPDATE log_messages SET unique_arguments = ['[email protected]...
^
Upvotes: 0
Views: 458
Reputation: 716
This should work. You are not enclosing your list string within quotes.
sql_test = "UPDATE log_messages SET unique_arguments = \"%s\" , sent_to = %s where log_id = %s " % (unique_arguments_list,email_send_to,str(log_id))
Upvotes: 1