sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Support the PostgreSQL engine on Windows

Open dharmjit opened this issue 5 years ago • 12 comments

Hi, I just started exploring this project. But not able to build the project on windows. Is windows support in the road map. Thanks

dharmjit avatar Jan 20 '20 12:01 dharmjit

Can you specify the error message?

eullerpereira94 avatar Jan 20 '20 12:01 eullerpereira94

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.

dharmjit avatar Jan 20 '20 13:01 dharmjit

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:

  1. if you are in Windows 10, activate WSL2, and use sqlc within the Linux subsystem. Be sure to install gcc on it.
  2. 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.

eullerpereira94 avatar Jan 20 '20 13:01 eullerpereira94

@kyleconroy @euller88 how about providing a binary file on every releases? user can download directly?

landbed avatar Mar 13 '20 09:03 landbed

@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.

kyleconroy avatar Mar 13 '20 21:03 kyleconroy

Hi @kyleconroy, windows binaries then will not be useful for people using postgresql.

dharmjit avatar Mar 14 '20 10:03 dharmjit

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.

766b avatar Jun 19 '20 22:06 766b

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.

kyleconroy avatar Feb 08 '21 16:02 kyleconroy

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.

It's not working on WSL as well. This is my try: 2022-02-17_20h38_07

arif2009 avatar Feb 17 '22 14:02 arif2009

Hello any updates regarding this issue? is there a possibility for postgresql support in windows soon?

bmerracho avatar Mar 20 '22 17:03 bmerracho

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.

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

pawlobanano avatar Apr 06 '22 21:04 pawlobanano

I ended up installing sqlc with homebrew on WSL

gafful avatar Aug 25 '22 14:08 gafful

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.

NinoFoxx avatar Jan 02 '23 02:01 NinoFoxx

@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.

eullerpereira94 avatar Jan 03 '23 12:01 eullerpereira94

You can always open an issue on the pg_query_go repository.

This issue seems to track that already. Thanks.

NinoFoxx avatar Jan 03 '23 23:01 NinoFoxx

Oh wow, tried the WSL workaround, but still didnt work, damn

GustavoCielo avatar Jan 05 '23 12:01 GustavoCielo

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

malcolmmaima avatar Jan 23 '23 09:01 malcolmmaima

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?

mulukenhailu avatar Jul 04 '23 21:07 mulukenhailu

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

kokodayou2000 avatar Jul 05 '23 08:07 kokodayou2000

Just run that command exactly as it is... do not change anything

robinmuhia avatar Jul 05 '23 09:07 robinmuhia

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.

It's not working on WSL as well. This is my try:

2022-02-17_20h38_07

install sqlc through go install in wsl then try this: ~/go/bin/sqlc generate

Tesohh avatar Aug 02 '23 09:08 Tesohh

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.

andrewmbenton avatar Aug 30 '23 06:08 andrewmbenton

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 avatar Oct 15 '23 08:10 Ali-Adel-Nour

@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".

andrewmbenton avatar Oct 15 '23 14:10 andrewmbenton

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.

bontusss avatar Nov 24 '23 10:11 bontusss