繁体   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