Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prisma how to look into the database

I have followed https://www.prisma.io/docs/get-started/01-setting-up-prisma-new-database-JAVASCRIPT-a002 and gotten it to work. I can see the following:

  • docker ps tells me that two docker containers are being run
  • running node index.js each time shows a list of all users that have been created. hence, there is a database somewhere
  • When I try docker exec -it POSTGRE_CONTAINER_ID bash, I get a command prompt.
  • on the command prompt, when I type psql or psql prisma, i get psql: FATAL: role "root" does not exist

How do I see in which database/table is prisma saving my data in, and how do I connect to it?

like image 236
Amarsh Avatar asked Jan 28 '26 10:01

Amarsh


1 Answers

Prisma doesn't store data in the public schema by default. It stores it in an schema derived from your service name (default$default is the default when no service and stage is provided in the endpoint).

You can do the follow steps to see the underlying data:

  1. Grab the docker container id using docker ps
  2. Run docker exec -it <POSTGRES_CONTAINER_ID> psql -U prisma
  3. List all the schemas using \dn to grab all schemas, and find the schema that your service is using(it is default$default by default)
  4. Now run SET search_path to <YOUR_SCHEMA_NAME_FROM_STEP_3>; to change the default search path
  5. Run \dt to list all tables. You can also run any SQL command now on that schema.
like image 190
Harshit Pant Avatar answered Jan 31 '26 01:01

Harshit Pant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!