我正在尝试在 Python 脚本中针对 Redshift DB 运行 SQL 查询。以下结果导致错误“TypeError:dict不是序列”,我不明白为什么。
test1 = """
WITH A AS
(
SELECT *,
CASE WHEN substring(text_value, 0, 4) LIKE ' ' THEN substring(substring(text_value, 0, 4), 3) ELSE substring(text_value, 0, 4) END AS cost_center_id
FROM job_custom_fields
WHERE key = 'cost_center'
)
SELECT job_id,
display_value,
CASE WHEN cost_center_id LIKE '%T%' THEN SUBSTRING(cost_center_id, 1,1)
WHEN cost_center_id LIKE '%D%' THEN SUBSTRING(cost_center_id, 1,1)
WHEN cost_center_id LIKE '%P%' THEN SUBSTRING(cost_center_id, 1,1) ELSE cost_center_id END AS cost_center_id
FROM A
"""
red_engine = create_engine('postgresql+psycopg2://org_525:LZynsTS56PqPlHVhIIgUdDf1c1wuW4gD@redshift.greenhouse.io:5439/greenhouse')
test = pd.read_sql_query(test1,red_engine)
test
非常感谢任何帮助
繁星淼淼
相关分类