问题
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