gpt4 book ai didi

python - 无法验证查询结果

转载 作者:太空宇宙 更新时间:2023-11-03 15:03:37 25 4
gpt4 key购买 nike

    query = "SELECT serialno from registeredpcs where ipaddress = "
usercheck = query + "'%s'" %fromIP
#print("query"+"-"+usercheck)
print(usercheck)
rs = cursor.execute(usercheck)
print(rs)
row = rs
#print(row)
#rs = cursor.rowcount()
if int(row) == 1:
query = "SELECT report1 from registeredpcs where serialno = "
firstreport = query + "'%s'" %rs
result = cursor.execute(firstreport)
print(result)
elif int(row) == 0:
query_new = "SELECT * from registeredpcs"
cursor.execute(query_new)
newrow = cursor.rowcount()+1
print(new row)

我在这里尝试做的是在数据库匹配某个ipaddress 时从数据库中获取serialno 值。此查询是否工作正常。查询结果集 rs 应该是 0。现在我正在尝试使用该值并在 if else 构造中执行其他操作。基本上,我试图根据 ipaddress 值检查数据库中的唯一值。但是我收到了这个错误

error: uncaptured python exception, closing channel smtpd.SMTPChannel connected 
192.168.1.2:3630 at 0x2e47c10 (**class 'TypeError':'int' object is not
callable** [C:\Python34\lib\asyncore.py|read|83]
[C:\Python34\lib\asyncore.py|handle_read_event|442]
[C:\Python34\lib\asynchat.py|handle_read|171]
[C:\Python34\lib\smtpd.py|found_terminator|342] [C:/Users/Dev-
P/PycharmProjects/CR Server Local/LRS|process_message|43])

我知道我犯了一些非常基本的错误。我认为这是导致错误的粗体部分。但就是不能把我的手指放在上面。我尝试使用 rowcount() 方法没有帮助。

最佳答案

rowcount 是属性,不是方法;你不应该调用它。

关于python - 无法验证查询结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35268957/

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