dbcli / pgcli

Postgres CLI with autocompletion and syntax highlighting
http://pgcli.com
BSD 3-Clause "New" or "Revised" License
12.14k stars 557 forks source link

Can't pipe input from external file #307

Open dylanpyle opened 9 years ago

dylanpyle commented 9 years ago

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.

amjith commented 9 years ago

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.

leonmax commented 6 years ago

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

fpietka commented 6 years ago

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

beauraines commented 3 years ago

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

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

stephane-klein commented 1 year ago

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

leonmax commented 11 months ago

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

j-bennet commented 11 months ago

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.