这里的data
变量将从cur.fetchall()
函数返回一个元组,看起来像这样
((1,'random_email1@mail.com','First_name1','Last_name1'),
(2,'random_email2@mail.com','First_name2','Last_name2'),
(3,'random_email3@mail.com','First_name3','Last_name3')...)
如果您需要查找具有特定电子邮件地址的行,我建议您为您执行此 SQL 命令
email_query = "SELECT * FROM login_info WHERE email = %s"
values = (email)
cur.execute(email_query, values)
data = cur.fetchone()
#Assuming that there will be only one Row with the E-mail ID as the PRIMARY KEY
然后数据元组将只包含 SQL 表中的一行,如下所示
(1,'random_email1@mail.com','First_name','Last_name')
在这里,您可以简单地使用data[1]
which is where the email is in the tuple 来获取电子邮件地址值。