gpt4 book ai didi

python - 看不到postgresql数据库访问程序的输出

转载 作者:行者123 更新时间:2023-11-29 12:25:26 24 4
gpt4 key购买 nike

def bul():

global entry_bul
pencere = Toplevel()

etiket= Label(pencere,text="\n# Which record do you want to find?Please enter the Student ID number.\n")
etiket.pack()

entry_bul=Entry(pencere)
entry_bul.pack()

btn = Button(pencere,text="Find the student",bg="orange",fg="navy",command=sorgula)
btn.pack()

def sorgula():

conn = connect(database="dorm", user="postgres", password="605394", host="127.0.0.1", port="5432")
print "Opened database successfully"
cur = conn.cursor()
cur.execute("SELECT * FROM pers_info, school_info, room_info WHERE ID_num = (%s) ;", (entry_bul.get(),));
rows = cur.fetchall()
for row in rows:
print row[0], row[1], row[2], row[3],row[4]

print "Operation done successfully";
conn.commit()
conn.close()

这些函数运行没有错误。但它不会在屏幕上给出 for 循环的输出。屏幕上的结果是:

Opened database successfully
Operation done successfully

最佳答案

基于“成功打开数据库”和“成功完成操作”之间的空行,我假设 for 循环中的打印语句只运行一次,并且第一行也是唯一一行没有值。

关于python - 看不到postgresql数据库访问程序的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41448578/

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