Feb-02-2020, 07:15 AM
Hello,
I want to display data from my "quote" table by selecting an author in my table author selected "author" in my combobox. The search must be strictly equal to the name of the author selected in my combobox "cmb_author".
Thanks for your help.
Should we use LIKE?
I tried in my request, but it doesn't work.
my combobox
error line 5
I want to display data from my "quote" table by selecting an author in my table author selected "author" in my combobox. The search must be strictly equal to the name of the author selected in my combobox "cmb_author".
Thanks for your help.
Should we use LIKE?
I tried in my request, but it doesn't work.
my combobox
def cmb_author(event=None): global data1 connexion = sqlite3.connect('mnesis.db') cursor = connexion.cursor() cursor.execute("SELECT author_author FROM tb_author ORDER BY author_author") data1 = [] for row in cursor.fetchall(): data1.append(row[0]) return data1my request
error line 5
Quote: curseur.execute("SELECT * FROM tb_quote WHERE author_author LIKE \'%' + data1 + '%\'")
sqlite3.OperationalError: no such column: data1
def query_author(): connexion = sqlite3.connect('mnesis.db') curseur = connexion.cursor() curseur.execute("SELECT * FROM tb_quote WHERE author_author LIKE \'%' + data1 + '%\'") resultDatabase = curseur.fetchall() # query results = '' for row in resultDatabase: results += '\n'.join([ 'Auteur: {}'.format(row[1]), 'Citation: {}'.format(row[2]), 'Référence: {}'.format(row[3]), '-----------------------\n' ])