簡體   English   中英

數據庫行列選擇問題<sqlite3.Row object at 0x000001DE5B746D50>得到這個奇怪的回報

[英]Problem with database row and column selection <sqlite3.Row object at 0x000001DE5B746D50> getting this wierd return

您好,當我嘗試使用 sqlite 進行數據庫管理項目時,我遇到了這個問題。 代碼是

import sqlite3
class DBConnect():
    def __init__(self):
        self.db=sqlite3.connect("Registrations.db")
        self.db.row_factory=sqlite3.Row
        self.db.execute("create table if not exists Ticket(ID integer Primary key autoincrement,name text,gender text,comment text)")
        self.db.commit()
    def Add(self,Name,gender,comment):
        self.db.row_factory=sqlite3.Row
        self.db.execute("insert into Ticket(name,gender,comment) values(?,?,?)",(Name,gender,comment))
        self.db.commit()
        return "DATA ADDED SUCCESFULLY"
    def Show(self):
        self.db.row_factory = sqlite3.Row
        cursor=self.db.execute("select * from Ticket").fetchall()
        print(type(cursor))
        return cursor

我沒有得到任何行數據,而是得到了它存儲的地址,就像這個 <sqlite3.Row object at 0x000001DE5B746D50>

我認為您正在嘗試打印行的內容,即Name Gender etc但最終打印了對象的類型print(type(cursor))這是<sqlite3.Row object at 0x000001DE5B746D50>

要打印行的內容,您可以嘗試print(cursor)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM