0
pd.read_sql("SELECT * FROM usd_rates;", conn)

   id        date                                  revenue_rates_usd
0  93  2021-07-23  {'AED': 3.673, 'AFN': 79.600004, 'ALL': 103.8,...
1  94  2021-07-24  {'AED': 3.673, 'AFN': 79.600004, 'ALL': 103.8,...
pd.read_sql("SELECT date as date, revenue_rates_usd ->> 'SAR' AS SAR FROM usd_rates;", conn)

         date       sar
0  2021-07-23  3.750918
1  2021-07-24  3.750712
pd.read_sql("SELECT date as date, revenue_rates_usd ->> 'SAR' AS SAR WHERE date BETWEEN '2021-07-23' AND '2021-07-24', FROM usd_rates';", conn)

错误 = sql 'SELECT date as date,income_rates_usd ->> 'SAR' AS SAR WHERE date BETWEEN '2021-07-23' AND '2021-07-24', FROM usd_rates';' 执行失败:语法错误靠近“,”第 1 行:...R 日期在 '2021-07-23' 和 '2021-07-24' 之间,来自 usd...

4

1 回答 1

0

在“From”之前有一个逗号(,),而“From”在“Where”之后,这可能就是问题所在。

pd.read_sql(“选择日期作为日期,receiver_rates_usd ->> 'SAR' AS SAR FROM usd_rates WHERE date BETWEEN '2021-07-23' AND '2021-07-24';”,conn)

于 2021-07-24T02:05:04.143 回答