* Add `--ping` as a CLI option
This builds in the functionality asked for in #1470; it allows pgcli to
replace `pg_isready` from the postgresql command line toolchain
* Update the changelog and AUTHORS
* Use click.echo
pgcli.echo doesn't seem to actually _echo_ anything
* Add integ tests for the ping feature
* Refactor try / else
Co-authored-by: Damien Baty <damien@damienbaty.com>
* Unused variable
---------
Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
Co-authored-by: Damien Baty <damien@damienbaty.com>
* Add --log-file & \log-file option to always capture output
Currently outputting to a file via \o disables the console output
This patch adds a `--log-file` cli arg with similar behavior to `psql`* and a \log-file
special command to enable/disable it from the console
*https://www.postgresql.org/docs/current/app-psql.html#APP-PSQL-OPTION-LOG-FILE
* switch to use context manager
Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
* switch to use context manager
Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
* use isoformat explicitly
Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
* change test to use a mock, update changelog & authors
* reformat
* black
---------
Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
`pgcli` uses Pendulum to display the query execution time in words:
> select pg_sleep(62)
+----------+
| pg_sleep |
|----------|
| |
+----------+
SELECT 1
Time: 62.066s (1 minute 2 seconds), executed in: 62.063s (1 minute 2 seconds)
Pendulum 3 (which has been released in December 2023 and is now
written in Rust) does not build on 32-bit architectures [1]. As such,
installing `pgcli` on such architectures fails. We could pin Pendulum
to version 2 (which was written in Python and builds "everywhere"),
but requiring a whole library and its own dependencies for such a
small feature seems unwarranted.
This commit thus removes the requirement on Pendulum and replaces it
by a simple "duration-to-words" function.
Fixes#1451.
[1] Upstream issue: https://github.com/sdispater/pendulum/issues/784
* Fix - Raised notices are printed backwards #1443
* updated changelog
* removed a print
* fixed up syntax error
* removing unneeded Nones from output
* rem var due to github recommendation
* adjusting if statements.
The application_name to be used when connecting to a database can now be
specified as a command line argument (--application-name) or be taken
directly from environment variables (PGAPPNAME). It still defaults to
'pgcli' when not specified.
Closes#1421.
When connecting to an IPv4 address (`pgcli -h 127.0.0.1`), trying to
use the "short host" in the prompt (with `\h`) would only display the
first octet (127). Now it shows the full IP.
Fixes#964.
* Fix deprecation.
* Drop python 3.7 and add 3.12.
* Bump pendulum.
* Changelog.
* Update gh actions.
* See if things pass without this scenario.
* Skip failing scenarios in 3.12.
* runs test on main branch as well.
reasons:
- tests passed on PR branches do not mean they will pass on main branch,
for e.g. alice changed A in branch-a, bob changed B in branch-b, both
tests passed and no conflict, but after merged to main, a bug occurs.
- wanna fix the badge in main branch ;D
* change the badge status to main branch only.
* fix psycopg.sql.Identifier in \ev handling (#1384)
* Allow defining a json file with preferred aliases
At $WORK we have a lot of tables with names like `foo_noun_verb` or
`foo_noun_related-noun_verb` and so while the default aliasing is very
helpful for shortening unwieldy names we do end up with lots of aliases
like `LEFT JOIN fnv on fnv2.id = fnv.fnv2_id`
This change will allow defining a json file of preferred aliases
```
> cat ~/.config/pgcli/aliases.json
{
"foo_user": "user",
"foo_user_group": "user_group"
}
```
so the alias suggestion for `SELECT * FROM foo_user` will be `SELECT * FROM foo_user AS user`
instead of the default `SELECT * FROM foo_user AS fu`
* When cannot open or parse alias_map_file raise error
Raise a (hopefully) helpful exception when the alias_map_file cannot be
parsed or does not exist
* Add tests for load_alias_map_file
* Add tests for generate_alias
* Update AUTHORS file
* Remove comment.
Discussed this on the PR with a project maintainer
---------
Co-authored-by: Andy Schoenberger <akschoenberger@gmail.com>
Co-authored-by: Rob B <rob@example.com>
Co-authored-by: Irina Truong <i.chernyavska@gmail.com>
If user tries to quit the cli while a transaction is ongoing (i.e.
begun, but not committed or rolled back yet), pgcli now asks for a
confirmation. The user can choose to commit, rollback or cancel the
exit. If the user chooses to commit or rollback, we exit only if the
commit/rollback succeeds.
Fixes#1071.
When this option is on, any statement that is deemed destructive
(through the use of the `destructive_warning` config option) will
not be executed unless a transaction has been started.