gpt4 book ai didi

python - MySQL + python 表 FETCH 模块

转载 作者:行者123 更新时间:2023-11-29 19:16:46 25 4
gpt4 key购买 nike

name=input("input CUSTOMERID to search :")

# Prepare SQL query to view all records of a specific person from
# the SALESPRODUCTS TABLE LINKED WITH SALESPERSON TABLE.
sql = "SELECT * selling_products.customer \
FROM customer \
WHERE customer_products.CUSTOMERID == name"

# Execute the SQL command
cursor.execute(sql)

# Fetch all the rows the sql result of SQL1.
results = cursor.fetchall()
print("\n\n****** TABLE MASTERLIST*********")
print("CUSTOMERID \t PRODUCTID \t DATEOFPURCHASE")
print("**************")

for row in results:
print (row[0],row[1],row[2])

Python 会编译上面的代码,但不会返回任何输出。非常感谢您的帮助:)

最佳答案

我认为你的sql应该是:

sql =    """SELECT * selling_products.customer 
FROM customer
WHERE customer_products.CUSTOMERID == {name}""".format(name=name)

关于python - MySQL + python 表 FETCH 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42641768/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com