pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

Can't pipe input from external file

Open dylanpyle opened this issue 9 years ago • 7 comments

This works fine in the default psql client, but not pgcli:

$ pgcli -U postgres -h localhost -p 5433 mydb < migration.sql
Version: 0.18.0
Chat: https://gitter.im/dbcli/pgcli
Mail: https://groups.google.com/forum/#!forum/pgcli
Home: http://pgcli.com
Traceback (most recent call last):
  File "/usr/local/bin/pgcli", line 9, in <module>
    load_entry_point('pgcli==0.18.0', 'console_scripts', 'pgcli')()
  File "/Library/Python/2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/pgcli/main.py", line 457, in cli
    pgcli.run_cli()
  File "/Library/Python/2.7/site-packages/pgcli/main.py", line 263, in run_cli
    document = cli.run()
  File "/Library/Python/2.7/site-packages/prompt_toolkit/interface.py", line 269, in run
    with self.input.raw_mode():
  File "/Library/Python/2.7/site-packages/prompt_toolkit/input.py", line 65, in raw_mode
    return raw_mode(self.stdin.fileno())
  File "/Library/Python/2.7/site-packages/prompt_toolkit/terminal/vt100_input.py", line 335, in __init__
    self.attrs_before = termios.tcgetattr(fileno)
termios.error: (25, 'Inappropriate ioctl for device')

Version 0.18.0

This might not be a bug, but would be a great feature IMO given that compatibility with the standard client seems to be a goal.

dylanpyle avatar Jul 30 '15 18:07 dylanpyle

You're right. That is not supported.

The intent of pgcli is for interactive usage. So I didn't concentrate on reading from an input stream.

In all honesty this is a low priority at the moment in terms of catching up with psql features.

amjith avatar Jul 30 '15 18:07 amjith

In that case, can you print the message that it is not supported instead of throwing confusing traceback?

leonmax avatar Jul 17 '18 18:07 leonmax

@leonmax I'm currently working on it. Sorry for the delay, I'll do my best to get it ready ASAP.

fpietka avatar Jul 18 '18 08:07 fpietka

Check out this comment - you can pipe some external file with some caveats.

https://github.com/dbcli/pgcli/issues/990#issuecomment-950209716

beauraines avatar Oct 23 '21 20:10 beauraines

@leonmax I'm currently working on it. Sorry for the delay, I'll do my best to get it ready ASAP.

@leonmax some news about this implementation?

stephane-klein avatar Oct 01 '23 06:10 stephane-klein

@leonmax I'm currently working on it. Sorry for the delay, I'll do my best to get it ready ASAP.

@leonmax some news about this implementation?

@stephane-klein, @fpietka mentioned me stating that he was working on it. I'm not aware of his progress 😜

leonmax avatar Dec 10 '23 08:12 leonmax

That comment from @fpietka was in 2018, I don't think it's very relevant now. :)

We all do our best to contribute, but life gets in the way. Also, as Amjith pointed out above, non-interactive use cases are much less of a priority. psql is your best bet there.

If you feel like submitting a PR to help, it would be very welcome.

j-bennet avatar Dec 11 '23 04:12 j-bennet