如何使用postgresq在链表python中显示db表中的所有值

2024-04-27 01:07:32 发布

您现在位置:Python中文网/ 问答频道 /正文

def Display(self):

    # current is assign head value

    current = self.head

    # if head is empty it excute this statment of empty list

    if self.head is None:
        print("--------- Sorry it's an Empty List ---------")
        return
    print(
        "--------------- ALL Account HOlder List ---------------\n Account_No      |      Name      |      "
        "Contact_No      |      Type      |      Amount|      Password")




    # if list  is not none it excute thst statment and show the attribute of account

    while current is not None:
        print("   ", current.number, "                ", current.name, "              ", current.contact,
              "                ", current.type, "             ", current.amount, "         ", current.password)
        cur.execute("SELECT id, name, contact, type, amount, password FROM customer ")
        conn.commit()
        current = current.next

这个方法并没有显示任何内容,但当我在控制台中运行这个查询时,它会显示表中的所有值。即使我关闭程序并再次运行,当我运行显示功能时,它也不会显示任何内容


Tags: ofselfnoneifisitaccountcurrent