这段python代码有问题,因为我不确定如何实现sql语句中的用户输入。
print("What two companies would you like to compare? ")
Company1 = input("What is the first compaany you would like? ")
Company2 = input("What is the second company you would like to add? ")
comData = [Company1, Company2]
carComData = (comData)
cursor.execute("Select * from Cars where (Car_brand like?) or (Car_brand like?) order by car_id",(carComData))
cursor.execute(sql)
result = cursor.fetchall()
df = pd.DataFrame(result, columns=['Car_id', 'Car_Brand', 'Car_Model', 'Year', 'VIN', 'KmsTravelled', 'Price', 'Dealer_id'])
print (df) '''
1条答案
按热度按时间xeufq47z1#
试试这个
你的问题是你的参数在一个列表而不是元组中。