Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows support? #25

Open
petsuter opened this issue May 22, 2018 · 5 comments
Open

Windows support? #25

petsuter opened this issue May 22, 2018 · 5 comments

Comments

@petsuter
Copy link

petsuter commented May 22, 2018

pgsanity 0.2.9
ecpg 10.1
Python 2.7.13
Windows 10

echo select column1 alias2 asdf from table3>example.sql

When I run pgsanity example.sql I get Try "ecpg --help" for more information..
(Running ecpg -o - - outputs the same message Try "ecpg --help" for more information..)

Maybe Windows is not supported?

@markdrago
Copy link
Owner

I can say that I have never tried to use pgsanity, or ecpg (or postgresql for that matter) on Windows. I suppose if you were able to get ecpg running reliably on windows it would be theoretically possible to get pgsanity to work there. If you have any patches for pgsanity to make that work I'd be happy to merge them, but it looks like this is more an issue with ecpg on windows than an issue with pgsanity.

@petsuter
Copy link
Author

petsuter commented May 25, 2018

I have never used ecpg before, so I don't exactly know what I should expect, but ecpg -o out.txt example.sql runs without errors / warnings and generates out.txt.

ecpg -o - example.sql also runs and prints the output to the console instead. Is that what -o - is supposed to do? So I assume ecpg -o - - is supposed to read the input from stdin instead? I could not find the documentation for this. It seems only that scenario is not supported on Windows. Is this a special feature of ecpg? Or a general feature of Linux shells?

I noticed pgsanity used to use temporary files instead of this ecpg -o - - trick. Possibly that approach would have worked on Windows.

I understand if this is not something you want to support. Thanks anyway.

@markdrago
Copy link
Owner

Okay, took me a second to remember what is going on here. It's better to think of the ecpg command here as having two pieces, one is "-o -" and the other is ... "-". The "-o -" piece is telling ecpg to output the results to stdout rather than to a named file. The second part, "-", is telling ecpg to read from stdin rather than reading from a named file. I'd like to keep it working that way if possible. I know very little about windows development or the windows environment in general for that matter. Are you running this in some linux/unix emulation environment like WSL? Provided you have a capable shell this should work out without issue. Do you have 'cat' available? Can you run 'cat example.sql | ecpg -o - -'? Or perhaps try 'ecpg -o - - < example.sql'? Both of those should result in ecpg receiving the file on stdin. It's worth pointing out that ecpg doesn't operate on bare sql files, so you'll get some kind of an error as a result, but it should at least be able to read the contents from stdin.

@markdrago markdrago reopened this May 25, 2018
@petsuter
Copy link
Author

petsuter commented May 25, 2018

OK thanks for the clarification.

(Now on ecpg 10.4)

I had already tried ecpg -o - - < example.sql but that also just prints Try "ecpg --help" for more information.. cmd.exe has no cat; the crude equivalent would be type example.sql | ecpg -o - -. Again this just prints Try ....

This was all attempted in the "dumb" basic Windows shell (cmd.exe) without WSL or any other linux/unix emulation layer. I tried it under WSL now but get the same message again.

Looking at ecpg source I see now that - is indeed a ecpg feature. So maybe it's not Windows-related at all. I don't understand why stdin redirection doesn't work though.

(I guess it's also not really a pgsanity-related problem.)

@Zeckels
Copy link

Zeckels commented Mar 9, 2020

Hello, I am also having this same issue. I am on Windows 10 trying to call the following command from git Bash:
echo "select a from b" | pgsanity

I receive this error:
Try "ecpg --help" for more information.

Has a workaround been identified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants