Support the PostgreSQL engine on Windows
Hi, I just started exploring this project. But not able to build the project on windows. Is windows support in the road map. Thanks
Can you specify the error message?
I am getting below error.
github.com\lfittl\[email protected]\parser\include/port.h:17:19: fatal error: netdb.h: No such file or directory compilation terminated.
Ah, the dreaded "missing C header files" error. First, this seems like a problem within pg_query_go and the C header files available on your system. I have two recommendations for you:
- if you are in Windows 10, activate WSL2, and use sqlc within the Linux subsystem. Be sure to install gcc on it.
- Try the vendoring instructions present in the pg_query_go repo, and see if it works.
I will research a little bit more in order to see if there is some other options, but those two are the ones that were on the top of my mind.
@kyleconroy @euller88 how about providing a binary file on every releases? user can download directly?
@landbed that is already the case. You can download macOS and Linux binaries for every commit on master. Each release also has binaries.
The issue is that out PostgreSQL parser does not support Windows. Once MySQL support is complete, we'll offer a Windows version that does not support PostgreSQL.
Hi @kyleconroy, windows binaries then will not be useful for people using postgresql.
Just FYI, you can run sqlc on Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.
Initial Windows support is now live (#886).
GOOS=windows GOARCH=amd64 go build ./cmd/sqlc/
These builds have a huge limitation: the PostgreSQL engine does not work. While that's obviously not ideal, it's good for those people that only need MySQL support.
Just FYI, you can run
sqlcon Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.
It's not working on WSL as well. This is my try:

Hello any updates regarding this issue? is there a possibility for postgresql support in windows soon?
Just FYI, you can run
sqlcon Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.It's not working on WSL as well. This is my try:
Fortunately it is working. There is a little hack for the lack of systemd in WSL2, but it is surmountable via commands mentioned here: https://github.com/microsoft/WSL/issues/5126#issuecomment-1001240706
and then simple install: sudo snap install sqlc
I ended up installing sqlc with homebrew on WSL
I'm sorry for being rude but how is this 3 years in and still not fixed?!
I've just started migrating a new project from GORM and this is honestly unacceptable.
The WSL workaround is not enough, I think the parser should have native Windows support.
@NinoM4ster the parser is a different project that is not maintained by Kyle. You can always open an issue on the pg_query_go repository. Also, any contributions towards a parser that works on Windows would be greatly appreciated.
You can always open an issue on the pg_query_go repository.
This issue seems to track that already. Thanks.
Oh wow, tried the WSL workaround, but still didnt work, damn
sqlc generate
Gives:
C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows
Possible solution in windows (worked for me):
docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate
sqlc generate
Gives:
C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows
Possible solution in windows (worked for me):
docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate
please, can you explain step by step how it worked for you on Windows?
sqlc generate
Gives:
C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows
Possible solution in windows (worked for me):
docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate
please, can you explain step by step how it worked for you on Windows?
sqlc generate
Gives:
C:\Users\Malcom\Github....\db\migration\000001_init_schema.up.sql:1:1: the PostgreSQL engine does not support Windows
Possible solution in windows (worked for me):
docker run --rm -v "%cd%:/src" -w /src kjconroy/sqlc generate
please, can you explain step by step how it worked for you on Windows?
I just ran into this issue as well
first use pwd command
get path
C:\Users\03062\Desktop\Code\workspace\project\golang\simplebank
second
copy the path
docker run --rm -v "C:\Users\03062\Desktop\Code\workspace\project\golang\simplebank:/src" -w /src kjconroy/sqlc generate
https://docs.sqlc.dev/en/latest/overview/install.html#docker
Just run that command exactly as it is... do not change anything
Just FYI, you can run
sqlcon Windows by installing Windows Subsystem for Linux then using compiled Linux binary. Probably can add this to readme as temporary work around for Windows users.It's not working on WSL as well. This is my try:
install sqlc through go install in wsl then try this: ~/go/bin/sqlc generate
There is an option to use sqlc with remote codegen execution, which is perhaps a suitable workaround for Windows PostgreSQL users: https://docs.sqlc.dev/en/stable/reference/changelog.html#remote-code-generation
Otherwise the best solution seems to be using a downloaded release binary with WSL.
I am closing this issue since pg_query_go likely won't be updated to support Windows, and the above workarounds are stable.
version: "2" packages:
- name: "db" path: "./db/sqlc" queries: "./db/query/" schema: "./db/migration/" engine: "postgresql" emit_json_tags: true emit_prepared_queries: false emit_interface: false emit_exact_table_names: false
I keep getting this error error parsing sqlc.yaml: yaml: unmarshal errors: line 2: field packages not found in type config.Config make: *** [Makefile:14: sqlc] Error 1
@Ali-Adel-Nour Your config structure looks like version "1" but you've specified version "2". Your config should parse if you set version: "1".
I decided to use the wsl workaround but it didn't see my database. I've installed postgres on wsl but there's no way to access it on pgadmin.