Json API and postgres

Hi, i tried persistence with postgres for my daml contracts with these commands:

daml deploy --host localhost --port 6865

java -jar daml-on-sql-1.17.1.jar --ledgerid=test --sql-backend-jdbcurl=“jdbc:postgresql://localhost/damlledger?user=daml&password=daml”

Those worked for me, but now i want to run JSON API and have postgres persistence, i tried these command but it doesnt store the contracts, any clue?

daml sandbox --wall-clock-time --ledgerid test_ledger ./.daml/dist/Tese-0.0.1.dar

daml json-api --ledger-host localhost --ledger-port 6865 --http-port 7575 --query-store-jdbc-config “driver=org.postgresql.Driver,url=jdbc:postgresql://localhost:5432/damltest?&ssl=false,user=usertest,password=usertest,createSchema=false” --allow-insecure-tokens

Welcome, @Bernardo. This could be one of several things; to clarify, when you say

where are you looking? That is, where are you expecting the contracts to be stored?

(NB: daml-on-sql.jar is not part of the Daml 2 product, as previously discussed here. Keep that in mind for your future deployment plans.)

1 Like

The contracts should be stored in postgres, When i reboot the sandbox, they should be visible in navigator and they are not. It doesn´t happend when i execute daml-on-sql.jar commands.

Thanks for the clarifying details; I think I see what you’re saying now.

The JSON API’s use of Postgres is not an alternative to the ledger server (on-sql in your first case, sandbox in your second) storage. It is an orthogonal cache, meant to improve the performance of queries; the ledger server is always its source of ledger data. Since the JSON API is, in reality, an ordinary ledger client, it cannot influence the configuration of the ledger server.

So the contracts disappear in your second example because only the sandbox’s storage matters, and sandbox is in-memory only; it cannot consult the JSON API to retrieve the ledger, which doesn’t keep the full ledger data anyway.

A production setup with JSON API and a Postgres-backed ledger server, such as Canton with Daml 2, will have Postgres for the ledger server, as well as a separate database for the JSON API’s cache.

1 Like

Thank you Stephen i think i understood, i will try it with Daml 2

2 Likes