![]() |
select one item from row with sqlite3 - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: select one item from row with sqlite3 (/thread-13015.html) |
select one item from row with sqlite3 - mcmxl22 - Sep-24-2018 I have a database consisting of 3 columns. I want to match just one item from one column. def interface(): '''Create interface allowing team members to bid starting with highest seniority.''' # Enter name name = input('Enter your name. ') # confirm name and current bid conn = sqlite3.connect('Bid.db') cursor = conn.cursor() sql = 'SELECT Name FROM Bid WHERE Name=?' results = cursor.execute(sql, name) #bid_list = results.fetchall() print(results) confirm = input(f'Is this you?\n{bid_list}\n') options = ('1 Yes', '2 No') print('\n'.join(options))current output: Enter your name. bob desired output:Enter your name. bob is this you? bob 1 Yes 2 No What am I doing wrong? RE: select one item from row with sqlite3 - ichabod801 - Sep-24-2018 cursor.execute is expecting a sequence for the second parameter. A sting is a sequence, so it tried to match 'b', 'o', and 'b' to the sql code. Try results = cursor.execute(sql, [name]) instead.
|