sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.51k stars 810 forks source link

error parsing sqlc.yaml: file does not exist #3708

Open NiketanSaini opened 6 days ago

NiketanSaini commented 6 days ago

Version

1.27.0

What happened?

I was trying to set up a Go project using sqlc. But facing the very annoying issue. Screenshot from 2024-11-15 17-16-36

Relevant log output

asus@asus-Vivobook-ASUSLaptop-M6500QC-M6500QC:~/Projects/BackendMasterClass/simplebank$ sqlc init
sqlc.yaml is already created
asus@asus-Vivobook-ASUSLaptop-M6500QC-M6500QC:~/Projects/BackendMasterClass/simplebank$ sqlc version
v1.27.0
asus@asus-Vivobook-ASUSLaptop-M6500QC-M6500QC:~/Projects/BackendMasterClass/simplebank$ sqlc generate
error parsing sqlc.yaml: file does not exist
asus@asus-Vivobook-ASUSLaptop-M6500QC-M6500QC:~/Projects/BackendMasterClass/simplebank$

Database schema

CREATE TABLE "account" (
  "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,
  "amount" bigint NOT NULL,
  "created_at" timestamptz DEFAULT (now())
);

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

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

CREATE INDEX ON "entries" ("account_id");

CREATE INDEX ON "transfers" ("from_account_id");

CREATE INDEX ON "transfers" ("to_account_id");

CREATE INDEX ON "transfers" ("from_account_id", "to_account_id");

COMMENT ON COLUMN "entries"."amount" IS 'can be negative and positive';

COMMENT ON COLUMN "transfers"."amount" IS 'only positve values';

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

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

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

SQL queries

SELECT * FROM account;

Configuration

version: "2"
sql:
  - schema: ./db/migration/000001_init_schema.down.sql   # Path to your schema or migration files
    queries: ./db/query/account.sql                     # Path where your SQL query files are stored
    engine: postgresql                                  # Database engine (e.g., postgresql, mysql, sqlite)
    codegen:
      go:
        package: github.com/techschool                  # Package name for generated code
        out: sqlc                                       # Directory where generated code will be placed
        emit_json_tags: true                            # Emit JSON tags in structs
        emit_prepared_queries: false
        emit_interface: false
        emit_exact_table_names: false

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go