This message was deleted.
# opal
s
This message was deleted.
a
Hi @Bart And and welcome 🙂 Check out this example repo, and specifically the configuration in docker compose: https://github.com/permitio/opal-fetcher-postgres
Copy code
OPAL_DATA_CONFIG_SOURCES={"config":{"entries":[{"url":"<postgresql://postgres@example_db:5432/postgres>","config":{"fetcher":"PostgresFetchProvider","query":"SELECT * from city;","connection_params":{"password":"postgres"}},"topics":["policy_data"],"dst_path":"cities"}]}}
you do not manipulate the save method at all (this determines how the data is saved to OPA) instead you use the fetcher custom config to pass what query you need to run against the db
Copy code
"query":"SELECT * from city;"
hope it helps 🙂
b
Hi, thanks a lot for quick response. I went trough all the documentation, but I still do not catch one thing. If we change the record in db, we still have ex. "select ... where id=xxx". When we add new record, have the same select.
and question how we can adapt/transform selected data to specific data structure on OPA side?
a
re:2 - you transform the data returned from DB to json in the process method of the fetcher
re:1 i'm not sure i am following. sending the update will fetch the select query in that moment and update the data in OPA. you will have to re-send the update through OPAL every time there is a change. OPAL will not know to track the database.
b
Thanks. ad1, may be add/update was wrong example as OPA API rest call looks the same. So just one more question, how can I notify OPA that record was deleted (in example data structure I remove specific city from cities table and want to update this record in OPA)? doing delta update, not reloading all cities.
a
Currently we do not have a delete instruction. There is an outstanding PR but there is still some work to do in order to merge it in. The the meanwhile structure your data as dictionaries / hash maps and not as lists. You can override a specific city record key by doing PUT on the city unique key and putting {} as value
b
OK, thanks a lot! Now it looks clear.