Skip to content

Basic usage - relation "x" does not exist #3350

@eyal-solomon1

Description

@eyal-solomon1

Version

1.26.0

What happened?

Getting relation "x" does not exist for every query I mention in my queries .sql files

Relevant log output

query.sql:1:1: relation "models" does not exist
query.sql:15:1: relation "models" does not exist
query.sql:20:1: relation "models" does not exist
query.sql:28:1: relation "models" does not exist

Database schema

CREATE TABLE `transcription_jobs` (
  `id` integer PRIMARY KEY,
  `org_id` integer,
  `user_id` integer,
  `started_at` timestamp,
  `ended_at` timestamp,
  `tokens` integer,
  FOREIGN KEY (`org_id`) REFERENCES `organization` (`org_id`)
);

CREATE TABLE `organization` (
  `org_id` integer PRIMARY KEY
);

CREATE TABLE `models` (
  `id` integer PRIMARY KEY,
  `model_name` VARCHAR(255),
  `balance` integer,
  `org_id` integer,
  FOREIGN KEY (`org_id`) REFERENCES `organization` (`org_id`)
);

SQL queries

-- name: CreateModel :one
INSERT INTO models (
    id,
    model_name,
    org_id,
    balance
) VALUES (
    :id,
    :model_name,
    :org_id,
    :balance
) RETURNING *;

-- name: GetModel :one
SELECT * FROM models
WHERE id = :id
LIMIT 1;

-- name: UpdateModel :one
UPDATE models
SET model_name = :model_name,
        org_id = :org_id,
        balance = :balance
WHERE id = :id
RETURNING *;

-- name: DeleteModel :one
DELETE FROM models
WHERE id = :id
RETURNING *;

Configuration

version: "2"
plugins:
  - name: "py"
    wasm:
      url: "https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.0.0.wasm"
      sha256: "aca83e1f59f8ffdc604774c2f6f9eb321a2b23e07dc83fc12289d25305fa065b"
sql:
  - schema: "path_to_folder"
    queries: "path_to_folder"
    engine: "sqlite"
    codegen:
      - plugin: "py"
        out: "src"
        options:
          package: "foo"
          emit_sync_querier: true
          emit_async_querier: true
          query_parameter_limit: 5

Playground URL

https://play.sqlc.dev/p/7150dcc1ccab07d5dcca915b08525b015d4f94968345157779d016a74eb04279

What operating system are you using?

macOS

What database engines are you using?

SQLite

What type of code are you generating?

Python

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions