在本地将Postgres数据库与Prisma连接

时间:2019-12-28 04:34:01

标签: postgresql prisma prisma-graphql

尽管我一直收到一条错误消息,但我仍尝试使用Arizonaa在本地连接到PostgreSQL数据库。

这是我的prisma.yml

version: '3'
services:
  prisma:
    image: prismagraphql/prisma:1.8
    restart: always
    ports:
    - "4466:4466"
    environment:
      PRISMA_CONFIG: |
        port: 4466
        # uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
        # managementApiSecret: my-secret
        databases:
          default:
            connector: postgres
            host:host.docker.internal
            database:esrtech-dev-server
            port:5432
            user:postgres
            password: p@ssw0rd
            migrations: true

尝试启动环境时收到以下错误:

Exception in thread "main" java.lang.RuntimeException: Unable to load Prisma config: while scanning a simple key
prisma_1  |  in 'string', line 7, column 5:
prisma_1  |         host:host.docker.internal

我也尝试在host内使用localhost,但仍然遇到相同的问题。

1 个答案:

答案 0 :(得分:0)

通常来说,此问题与YAML中特殊字符的使用有关。

根据您提供的信息,从数据库配置中的密码字段开始可能会有所帮助。

您的问题可以通过在密码中添加引号来解决。

password: "p@ssw0rd"

另一个用户遇到了类似的问题,可能会提供进一步的见解,可以在Prisma Github存储库(https://github.com/prisma/prisma/issues/2263)中找到该问题

否则,您可能需要提供有关环境的更多信息。通常,prisma提供的docker compose文件使用单独容器中的postgres数据库(通过相同的pyramida.yml管理)。