我正在尝试将参数传递给SQL查询,但是,我不知道我是否正确。
def getUser(user):
conn = databaseConnection()
cur = conn.cursor()
conn.set_client_encoding('LATIN1')
rows = cur.execute("SELECT * FROM mk_pessoas WHERE nome_razaosocial= %s",(user))
rows = cur.fetchall()
return rows
调用此函数:
row = getUser('brian')
print row
错误:
TypeError: not all arguments converted during string formatting