[英]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.您好,当我尝试使用 sqlite 进行数据库管理项目时,我遇到了这个问题。 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>我没有得到任何行数据,而是得到了它存储的地址,就像这个 <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>
.我认为您正在尝试打印行的内容,即
Name Gender etc
但最终打印了对象的类型print(type(cursor))
这是<sqlite3.Row object at 0x000001DE5B746D50>
。
To print the contents of the row you can try print(cursor)
要打印行的内容,您可以尝试
print(cursor)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.