No errors but not getting an expected output [duplicate]

浪尽此生 提交于 2021-01-29 07:15:10

问题


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):
        cursor=self.db.execute("select * from Ticket")
        print(type(cursor))
        return cursor.fetchall()

The program is expected to return a list/tuple having column name and corresponding value in each row. But the issue is when I print it I see something like this:

[<sqlite3.Row object at 0x000002C0748D6D50>, <sqlite3.Row object at 0x000002C0748D68F0>, <sqlite3.Row 
object at 0x000002C0748D6C50>, <sqlite3.Row object at 0x000002C0748D6D10>, <sqlite3.Row object at 
0x000002C0748D6890>, <sqlite3.Row object at 0x000002C0748D6D90>, <sqlite3.Row object at 
0x000002C0748D6870>, <sqlite3.Row object at 0x000002C0748D6750>, <sqlite3.Row object at 
0x000002C0748D6910>, <sqlite3.Row object at 0x000002C0748D6A70>]

There are no errors but selecting data from table returns their address. How do I solve this?

来源:https://stackoverflow.com/questions/64330984/no-errors-but-not-getting-an-expected-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!