Issue
I was making a killboard for EVE online and wanted to do a database search for certain words contained in the string. Here are all the column names of my database: id final_blow_name final_blow_ship_type victim_name victim_corporation victim_birthday victim_gender victim_security_status victim_ship_type sistem_security_status attackers_len
I did it using LIKE and WHERE. But it gives the error "no such column: the name I was looking for". Here is my code:
path = 'C:/Users/mrjol/PycharmProjects/myboard/board_veiw/database.db'
connection = sqlite3.connect(path)
cursor = connection.cursor()
search_request = str(request.session.pop('search_request', 'None'))
character_name_1 = search_request.partition(' ')[0]
character_name_2 = search_request.partition(' ')[2]
if character_name_2 != '':
search_request = character_name_1 + '_' + character_name_2
search_answer = cursor.execute('SELECT final_blow_name FROM Killmails WHERE final_blow_name = Cosmo_Blink')
connection.close()
Solution
The problem is here search_answer = cursor.execute('SELECT final_blow_name FROM Killmails WHERE final_blow_name = Cosmo_Blink')
. Syntactically, sql is looking for a column named Cosmo_Blink
. Use parameter substitution (binding) as described in the doc.
Answered By - DinoCoderSaurus
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.