我无法看到postgresql数据库访问程序的输出

时间:2017-01-03 16:58:46

标签: python postgresql python-2.7

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

1 个答案:

答案 0 :(得分:0)

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