prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Connect to an existing database PostgreSQL

Open riccardomerolla opened this issue 8 years ago • 10 comments

Bug Report

? Set up a new Prisma server or deploy to an existing server? Use existing database ? What kind of database do you want to deploy to? PostgreSQL ? Does your database contain existing data? Yes ? Enter database host localhost ? Enter database port 5432 ? Enter database user postgres ? Enter database password postgres ? Enter name of existing database six ? Enter name of existing schema public

Introspecting database... ! Error: Connection terminated by user at Client.end (/usr/local/lib/node_modules/prisma/node_modules/pg/lib/client.js:402:36) at Timeout._onTimeout (/usr/local/lib/node_modules/prisma/node_modules/prisma-db-introspection/src/connectors/PostgresConnector.ts:19:19) at ontimeout (timers.js:482:11) at tryOnTimeout (timers.js:317:5) at Timer.listOnTimeout (timers.js:277:5) util timed out +0ms Exiting with code: 0

prisma/1.8.3 (darwin-x64) node-v8.11.1

Reproduction

I have tried with different existing PostgreSQL databases, local or remote, but I always get this error.

Expected behavior?

riccardomerolla avatar May 21 '18 08:05 riccardomerolla

Thanks for bringing this up, @riccardomerolla!

I assume this has something to do with your environment, or the way your Postgres database is set up.

Can you share more information about that, so we can start looking into the underlying issue? A repository that reproduces the timeout would be of big help already.

Also, have you tried to connect to the database directly, using a Postgres client?

marktani avatar Jun 04 '18 16:06 marktani

Hi there! I'm also having this same problem connecting Prisma to my Postgres DB in an RDS instance. My DB also have existing data. Also, I'm currently successfully connecting to my RDS DB with Navicat and it works just fine. Let me know if you guys need more info or if I can be of any help to solve this issue. I'm really excited to use Prisma in my project.

@riccardomerolla Did you find a solution or maybe a workaround to the issue?

Kevinclap avatar Jul 04 '18 03:07 Kevinclap

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 18 '18 03:08 stale[bot]

I'm having the exact same problem with Prisma 1.15

@marktani Can you be specific about what further information you want? What does "how your database was set up" mean, exactly?

OS: macOS High Sierra 10.13.6 postgres (PostgreSQL) 10.5

Can this please be reopened?

benjamin-rood avatar Sep 01 '18 09:09 benjamin-rood

Can you provide a reproduction? 🙂I shared some relevant questions above https://github.com/prisma/prisma/issues/2481#issuecomment-394410574.

marktani avatar Sep 01 '18 09:09 marktani

I cannot provide a reproduction, I'm sorry, this is all private IP.

No issues with connecting to the database using psql + the prisma docker instance starts and connects to the database on the host ok. Running prisma deploy also works.

brpro ➜  prisma-test git:(develop) ✗ prisma introspect
  config CWD /Volumes/cs/vadadev-new/admin-poc-graphql-serverless-august-2018/prisma-test +0ms
  config HOME /Users/br +5ms
  config definitionDir /Volumes/cs/vadadev-new/admin-poc-graphql-serverless-august-2018/prisma-test +0ms
  config definitionPath /Volumes/cs/vadadev-new/admin-poc-graphql-serverless-august-2018/prisma-test/prisma.yml +0ms
  cli { isGlobal: true } +0ms
  StatusChecker setting status checker +0ms
  cli command id introspect +6ms
  cli:plugincache Got plugin from cache +0ms
  cli:plugincache /Users/br/Library/Caches/prisma/plugins.json +0ms
  cli:plugincache Got plugin from cache +1ms
  cli:plugincache /Users/br/Library/Caches/prisma/plugins.json +0ms
  plugins findCommand prisma-cli-core +0ms
  plugin requiring command +0ms
  cli-engine:plugins:manager requiring /Users/br/.nvm/versions/node/v9.4.0/lib/node_modules/prisma/node_modules/prisma-cli-core +0ms
  cli-engine:plugins:manager required +436ms
  plugin required command +439ms
  StatusChecker setting status checker +503ms
? What kind of database do you want to introspect? PostgreSQL
? Enter database host localhost
? Enter database port 5432
? Enter database user ******
? Enter database password  ******
? Enter name of existing database  ******_test
? Use SSL? No
? Enter name of existing schema public

Introspecting database... !
Error: Connection terminated by user
    at Client.end (/Users/br/.nvm/versions/node/v9.4.0/lib/node_modules/prisma/node_modules/pg/lib/client.js:402:36)
    at Timeout._onTimeout (/Users/br/.nvm/versions/node/v9.4.0/lib/node_modules/prisma/node_modules/prisma-db-introspection/src/connectors/PostgresConnector.ts:25:19)
    at ontimeout (timers.js:458:11)
    at tryOnTimeout (timers.js:296:5)
    at Timer.listOnTimeout (timers.js:259:5)
  util timed out +0ms
Exiting with code: 0

I've looked at the code, "timeout" is a canard. Something else is going on.

benjamin-rood avatar Sep 01 '18 09:09 benjamin-rood

Same problem with the last version. With psql no problem to connect to the database, prisma server run without error, but introspect doesn't work.

→ prisma introspect config CWD /private/tmp/sixlm +0ms config HOME /Users/riccardo +2ms config definitionDir /private/tmp/sixlm +0ms config definitionPath /private/tmp/sixlm/prisma.yml +0ms cli { isGlobal: true } +0ms StatusChecker setting status checker +0ms cli command id introspect +7ms cli:plugincache Got plugin from cache +0ms cli:plugincache /Users/riccardo/Library/Caches/prisma/plugins.json +1ms cli:plugincache Got plugin from cache +1ms cli:plugincache /Users/riccardo/Library/Caches/prisma/plugins.json +0ms plugins findCommand prisma-cli-core +0ms plugin requiring command +0ms cli-engine:plugins:manager requiring /usr/local/lib/node_modules/prisma/node_modules/prisma-cli-core +0ms
cli-engine:plugins:manager required +530ms plugin required command +533ms StatusChecker setting status checker +596ms ? What kind of database do you want to introspect? PostgreSQL ? Enter database host 172.29.1.11 ? Enter database port 5432 ? Enter database user postgres ? Enter database password postgres ? Enter name of existing database six_lulm_180608 ? Use SSL? No ? Enter name of existing schema public

Introspecting database... ! Error: Connection terminated by user at Client.end (/usr/local/lib/node_modules/prisma/node_modules/pg/lib/client.js:402:36) at Timeout._onTimeout (/usr/local/lib/node_modules/prisma/node_modules/prisma-db-introspection/src/connectors/PostgresConnector.ts:25:19)
at ontimeout (timers.js:427:11) at tryOnTimeout (timers.js:289:5) at listOnTimeout (timers.js:252:5) at Timer.processTimers (timers.js:212:10) Exiting with code: 1

riccardomerolla avatar Sep 17 '18 17:09 riccardomerolla

This might be related: https://github.com/prisma/prisma/issues/3136

marktani avatar Oct 04 '18 12:10 marktani

Hi Guys, I can tell you that with prisma/1.17.1 (darwin-x64) node-v9.4.0 this same database schema was able to be introspected okay, but only when I ran it in interactive mode.

benjamin-rood avatar Oct 04 '18 14:10 benjamin-rood

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 18 '18 15:11 stale[bot]