我已经成功地在 PowerSchool 中设置了我需要的插件来通过 Python 查询表,如下所示。我查看了 PowerSchool 库文档中的示例,但无法使用相同的方法成功查询特定表(同时应用任何过滤器)。我只能获取整个表(使用 SQL 查询时)或“HTTPError: 400 Client Error: Bad Request for url: ...”(使用参数时)。
import powerschool
import pandas as pd
client_id = 'client id goes here'
client_secret = 'client secret goes here'
my_credentials = (client_id, client_secret)
host_name = 'host name goes here'
ps = powerschool.PowerSchool(host=host_name, auth=my_credentials)
st = ps.get_schema_table('students')
# I have tried each of these and they all return the entire table
sql = '''SELECT * FROM STUDENTS WHERE last_name IN ('SMITH', 'JOHNSON')'''
params = {'last_name':'SMITH',
'projection':'last_name'}
stData = st.query(**params)
df = pd.DataFrame.from_dict(stData)
stData2 = st.query(body=sql)
df = pd.DataFrame.from_dict(stData2)
提前致谢!