Skip to content

[Error] there is allways - 'syntax error near " CREATE TABLE authors"' #3681

Open
@GARcraft

Description

@GARcraft

Discussed in #3680

Originally posted by GARcraft October 29, 2024
Windows 11 using docker (but if I try to use sql.exe, there is same results)

sqlc.yaml:

version: '2'
sql:
  - schema: "schema.sql"
    queries: "query.sql"
    engine: "mysql"
    gen:
      go:
        out: "MySqlExample"

schema.sql:

CREATE TABLE authors
(
    id   INTEGER PRIMARY KEY,
    name text NOT NULL,
    bio  text
);

query.sql:

-- name: ListAuthors :many
SELECT *
FROM authors
ORDER BY name;

command:

docker run --rm -v ${pwd}:/src -w /src sqlc/sqlc generate

response:

# package 
schema.sql:1:9: syntax error near "CREATE TABLE authors"

^ allways shows first line of schema.sql file

If I will try to use 'sqlite' instead of 'mysql' there is another error:

line 1:0 extraneous input '' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}
# package
schema.sql:1:1: extraneous input '' expecting {<EOF>, ';', ALTER_, ANALYZE_, ATTACH_, BEGIN_, COMMIT_, CREATE_, DEFAULT_, DELETE_, DETACH_, DROP_, END_, EXPLAIN_, INSERT_, PRAGMA_, REINDEX_, RELEASE_, REPLACE_, ROLLBACK_, SAVEPOINT_, SELECT_, UPDATE_, VACUUM_, VALUES_, WITH_}

Could someone has this issue? Please tell me what did you do, to make it work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions