使用输入的行作为PyMySQL的参数

问题描述 投票:0回答:0

是否可以使用 input 函数作为函数 cursor.execute 的参数来使用输入的行?

connect = pymysql.Connect(

)

l2 = input("Введите слово: ")
condition = l2.isalpha()

if condition == True:
    cursor = connect.cursor()

    cursor.execute("SELECT * FROM adjectives WHERE word = %s", (l2,))
    data = cursor.fetchall()
    cursor.close()
    connect.close()

    for i in data:
        print(str(i))

输入参数后没有任何反应

(附上代码结果和数据库部分的图片)

DataBase Code's result

在俄罗斯的 StackOverflow 上询问,但没有人回应。

python sql python-3.x database pymysql
© www.soinside.com 2019 - 2024. All rights reserved.