我有以下课程:
class SomeClass:
def __init__(self, name, date):
self.name = name
self.date = date
现在我在另一个模块中有一个函数,它连接到 SQLite 数据库并执行查询:
def getEntry(user):
data = []
connection = lite.connect(database)
with connection:
cur = connection.cursor()
cur.execute("SELECT name, date FROM table WHERE column = ?", [user])
events = cur.fetchall()
# instantiate an instance of `SomeClass`
return data
那么我将如何创建一个实例SomeClass
并将其传递name
给date
我新创建的实例?