Access datatables when using anvil app server local

Dear all,

thanks for your great product. We intend to use the app server to have our app local running. For development/debugging and testing it would be hepful to access the data stored in the datatables.
When using the online editor I can do that via the data tables service directly in the browser.

When working locally I can connect from a client (let’s say pdadmin or dbeaver) to the postgres database. but there are some problems:

  • the minor one is that the post changes every time I restart the server. I didn’t figure out how to set a fixed port for that
  • I see in the Schemas the datatables but now tables/data

I can write and read from the postgres database using anvil.tables modul. So data are stored and can be queried from the database.
As far as I understand anvil uses the json features of postgres, so data are not stored in “real tables”. How can I still access them in a useful way (as above mentioned for debugging, testing, development).

Thanks in advance

In the datatables service, each table has an identifier shown and you can use that to access the table via sql. (They are actually views populated by triggers which do indeed utilise the json functionality within postgresql, but can still be queried and manipulated).

Thanks Owen, create. What would be the easiest way to use this with the local postgres database embeeded into the anvil app server? With having in mind that we want to debug, test…

I’m not sure exactly what you’re asking, but you can manage the embedded database just like you can any other database. For example, I’ve used alembic and sqlalchemy to write database migrations for an anvil db and I query it using pgcli.