Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NiketanSaini opened this issue Nov 15, 2024 · 1 comment
Open

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

NiketanSaini opened this issue Nov 15, 2024 · 1 comment

Comments

@NiketanSaini
Copy link

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

@kyleconroy
Copy link
Collaborator

Are you installing sqlc via snap? If so, by default it can't read files on mounted volumes.

The easiest way to fix this is to download a pre-built binary instead of using snap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants