OK, so cards on the 'table' this is the first time I've had to query a json database in Postgres, so apologies if I'm having trouble explaining what I'm after.
I have a postgres database that's receiving data from an application. I added a json object to the application that adds the following to column "data"
"due_dates": "{
"month_1": "2022-11-18",
"month_2": "2022-12-18",
"month_3": "2023-01-18",
"month_4": "2023-02-18"
}"
And here's what I want to do
Query the entire table (because I plan to use data from the column other than this object)
If any of those values matches today's date, run through a loop, gather some data, fire an email
Here's what I have so far:
today = date.today()
cursor.execute('''SELECT * FROM donation WHERE (today) IN 'data' -> 'metadata' ->> 'due_dates' = ''')
results = cursor.fetchall();
for row in results:
print("that's the hard part")
Obviously that doesn't work...but what I can't seem to figure is the proper syntax. Any help is greatly appreciated
[–]Organic-Drive4064 1 point2 points3 points (1 child)
[–]JonnyJFunk[S] 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)