due to these bracket { and } in Hourly Status','{',''),'}','') causing the syntax error in query .How to pass these bracket as string in a f-string format?
query = f"""Select fd.serial_number,txidkey,cast(replace(replace(data->>'Hourly Status','{',''),'}','') as text) as description,TO_TIMESTAMP(TIME/1000+19800) as date_time,time,total_min from filter_data fd , total_sum ts
where fd.serial_number = ts.serial_number
and time between {yesterday10PM*1000} and {today6AM*1000}'''
>Solution :
just use double curly braces {{:
query = f"""\
Select fd.serial_number, txidkey, cast(\
replace(replace(data->>'Hourly Status','{{',''),'}}','') as text) \
as description,TO_TIMESTAMP(TIME/1000+19800) as date_time,time,total_min \
from filter_data fd , total_sum ts \
where fd.serial_number = ts.serial_number \
and time between {yesterday10PM*1000} and {today6AM*1000}
'''
You can also read about formatted strings here:
https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals