简体   繁体   中英

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

hii when i was trying to do a project on database management using sqlite i face this problem. the code is

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

Iam not getting any row data instead i get the address where it is stored like this <sqlite3.Row object at 0x000001DE5B746D50>

I think you are trying to print the contents of the row ie Name Gender etc but instead ended up printing the type of the object print(type(cursor)) which is <sqlite3.Row object at 0x000001DE5B746D50> .

To print the contents of the row you can try print(cursor)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM