sqlc-dev / sqlc

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

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

Open GARcraft opened 3 weeks ago

GARcraft commented 3 weeks ago

Discussed in https://github.com/sqlc-dev/sqlc/discussions/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: ``` yml version: '2' sql: - schema: "schema.sql" queries: "query.sql" engine: "mysql" gen: go: out: "MySqlExample" ``` schema.sql: ``` sql CREATE TABLE authors ( id INTEGER PRIMARY KEY, name text NOT NULL, bio text ); ``` query.sql: ``` 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 {, ';', 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 {, ';', 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.