簡體   English   中英

PostgreSQL引擎不支持Windows

[英]the PostgreSQL engine does not support Windows

我嘗試使用 sqlc package 生成 golang 代碼,但它說“PostgreSQL 引擎不支持 Windows” 我嘗試在 postgresql 中生成插入操作代碼,為此我使用了 postgresql alpine docker 圖像。

我的 sql.yaml 文件是

version: "1"
packages:
  - name: "db"
    path: "./db/sqlc"
    queries: "./db/query/"
    schema: "./db/migration/"
    engine: "postgresql"
    emit_json_tags: true
    emit_prepared_queries: false
    emit_interface: false
    emit_exact_table_names: false

帳號.sql

-- name CreateAccount: one
INSERT INTO accounts (
    owner,
    balance,
    currency
) VALUES(
    $1,$2,$3
) RETURNING *;

我的架構包含

CREATE TABLE "accounts" (
  "id" bigserial PRIMARY KEY,
  "owner" varchar NOT NULL,
  "balance" bigint NOT NULL,
  "currency" varchar NOT NULL,
  "created_at" timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE "entries" (
  "id" bigserial PRIMARY KEY,
  "account_id" bigint NOT NULL,
  "amount" bigint NOT NULL,
  "created_at" timestamptz NOT NULL DEFAULT (now())
);

CREATE TABLE "transfers" (
  "id" bigserial PRIMARY KEY,
  "from_account_id" bigint NOT NULL,
  "to_account_id" bigint NOT NULL,
  "amount" bigint NOT NULL,
  "created_at" timestamptz NOT NULL DEFAULT (now())
);

ALTER TABLE "entries" ADD FOREIGN KEY ("account_id") REFERENCES "accounts" ("id");

ALTER TABLE "transfers" ADD FOREIGN KEY ("from_account_id") REFERENCES "accounts" ("id");

ALTER TABLE "transfers" ADD FOREIGN KEY ("to_account_id") REFERENCES "accounts" ("id");

CREATE INDEX ON "accounts" ("owner");

我缺少什么? 在此處輸入圖像描述

關於#282 sqlc 不支持 PostgreSQL 為 windows。但您可以使用 docker 生成文件,如 sqlc 安裝指南中所述。(鏈接

docker run --rm -v $(shell pwd):/src -w /src kjconroy/sqlc generate

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM