Python psycopg2.ProgrammingError:列“0”;你的名字;不存在

Python psycopg2.ProgrammingError:列“0”;你的名字;不存在,python,postgresql,python-3.x,psycopg2,Python,Postgresql,Python 3.x,Psycopg2,当我试图上传带有代码的PlayerScore时 if Number.PlayerScore > Score.interact_database("SELECT Score FROM score WHERE Name = %s;" % Player_Name, False,)[0][0] 对于Python中的PostgreSQL数据库,我得到以下错误:psycopg2.ProgrammingError:列“your name”不存在,其中“your name”是变量Player\u nam

当我试图上传带有代码的
PlayerScore

if Number.PlayerScore > Score.interact_database("SELECT Score FROM score WHERE Name = %s;" % Player_Name, False,)[0][0]
对于Python中的PostgreSQL数据库,我得到以下错误:
psycopg2.ProgrammingError:列“your name”不存在
,其中“your name”是变量Player\u name。但是,当我在PostgreSQL查询工具中运行它时,它工作得很好。有人知道为什么会出现这种错误,以及我如何防止以后再次发生这种错误吗?

我认为我们需要看到更多的代码,但根据文档:

绝不,绝不,绝不使用Python字符串连接(+)或字符串参数插值(%)将变量传递给SQL查询字符串。甚至在枪口下也没有

尝试将参数作为cursor.execute()方法中的第二个参数传递。使用类似于:

cursor.execute("""SELECT Score FROM score WHERE Name = %(player)s""", {'player': player_name } )
cursor.fetchone()
应该有用。它还可以接受一组值