Is it possible to run PostgreSQL within IDX for development?

The project I am working on uses PostgreSQL database and I am wondering if I can install PostgreSQL server on IDX for local development?

Found a solution:

  1. add pkgs.postgresql_14 to your list of packages and rebuild your environment. All postgres server commands are available.
  2. init and start the db server like normal
# create pgdata folder
mkdir ~/pgdata

# initialize db 
initdb --pgdata=~/pgdata --username=postgres

# try to connect
psql -U postgres
1 Like

Instead of creating initdb etc. easier way is to add services.postgres

And add line below packages end like

services.postgres = {
  enable = true;   
  enableTcp = true;
};