我有一个mysql数据库,其中“user”表有f\u name,l\u name,password email(pk),通过它创建会话,表“friendgroup”有fg\u name(pk),email((pk),用户.email(FK)和具有电子邮件(pk,用户电子邮件(fk)),所有者电子邮件(pk,friendgroup.email(fk)),fg\u名称(pk,friendgroup.fg\u名称(fk)),以及下面的python flask文件。 登录帐户后,我想在聊天中添加一个朋友。我试图从会话['email']中修复它
def add_friend():
user = session['email']
friendgroups = _get_own_friendgroups(user) return
render_template('addFriend.html', friendgroups=friendgroups)
def _get_own_friendgroups(user):
cursor = mysql.connection.cursor()
#find all friendgroups that the user owns
find_owned_friendgroups = 'SELECT fg_name, description FROM friendgroup WHERE owner_email = %s ORDER BY fg_name ASC'
cursor.execute(find_owned_friendgroups, (user))
owned_friendgroups = cursor.fetchall()
cursor.close()
return owned_friendgroups
我希望输出将是一个打开的窗口,并在需要时积极使用add friend,但显示错误:
MySQLdb._exceptions.ProgrammingError: not all arguments converted during bytes formatting
python中的一个常见错误是使用
(bar)
而不是(bar,)
,前者不是元组。你知道吗尝试使用:
相关问题 更多 >
编程相关推荐