con=sqlite3.connect('D:/Aegle Intern/Michael Files New/Sim.db')
cursor=con.cursor()
cursor.execute('''select * from tbl_exprt_sim where member_count={} and spec1_trigger={} and sl_trigger={} and policy_effective_date={} and state={}'''.format(member_count[i],spec_trigger[i],sl_trigger[i],PED[i],S[i]))
The above screenshots are the problem I met. As you can see, I want to select all columns from a table with column state="Michigan". And I want to use .format method or similar methods to deal with this searching, because "Michigan" is an element in a list. (probably replace .format('Michigan") with something like .format(S[i])).
Please offer some helps! Thanks a lot!
CodePudding user response:
Your Error Reason may be this that your format word is string. But you pass only {} that represent integer. Please Replace your {} with '{}' this.
try this
cursor.execute("select * from tbl_exprt_sim where state='{}'".format('Michigan'))
copy all code for better result.