Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

To complement this, I recommend installing `pgcli`[https://www.pgcli.com/]. It's a near-drop-in-replacement for psql, and gives autocompletion, syntax highlighting, and semicolon forgiveness.

Even as someone already comfortable with psql, pgcli is extremely handy.




I went back and forth between psql and pgcli for several years, until I realized that pgcli tab-completes JOIN conditions.


Postgres supports JOIN USING. If your keys are named the same in both tables, say `user_id` then you can simply say

  SELECT *
  FROM parent
  JOIN child USING (user_id)
I personally think naming your primary keys with their full name instead of calling all of them `id` or `key` is better practice also.


And to complement that, I recommend Postgres Pager (https://github.com/okbob/pspg)


A drop-down autocomplete in a console? First time I've seen such a thing. Thanks for pointing out this tool.


That's part of prompt toolkit, a python library for building cli applications. Its creator actually reimplemented a number of applications in python with similar additions. Check out pyvim, pymux, ptpython, pypager and ptterm.


pgcli is nice

and it works great with pspg pager [https://github.com/okbob/pspg]

''\pager /usr/local/bin/pspg''


I wish there was an oracle database equivalent. The oracle SQL REPLs are both terrible but the cx_oracle python client library is decent so maybe a pgcli fork would be possible.


pspg supports MySQL and SQLite after sone configuration to their shell, might be possible for oracle as well?


Thanks! Just switched to this for a project I'm working on.


one big cons of pgcli appear when we deal with long query. even it support multiline and vi mode. we still can't integrate a formatter for convenient sake.


I second this motion.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: