1
0
Fork 0
Commit Graph

2360 Commits

Author SHA1 Message Date
Andrew 8cc22b9d3a
Add verbose_errors config and special command (#1455)
* Add verbose_errors config

* Update changelog

* Add special command

* Blackify
2024-03-26 15:31:38 -07:00
Andrew a7a70fdc92
Echo notifications (#1385)
* Echo notifications

* Blackify

* Clean up a bit

* Add test

* Blackify

* Update changelog

* Fix tests
2024-03-23 13:24:40 -07:00
Damien Baty 9f114c4549 feat: Replace pendulum by home-made duration-to-words function
`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
2024-02-20 12:51:20 +01:00
ERYoung11 96eb37fd19
Fix psycopg installation error on windows, Issue #1413 (#1449)
* Fix Issue #1413, win32 psycopg

* Fix Issue #1413, win32 psycopg

* fixing syntax error

* black fix to a test

---------

Co-authored-by: Irina Truong <637013+j-bennet@users.noreply.github.com>
2024-02-05 21:44:05 -08:00
ERYoung11 27b2bc2d37
Raised notices (#1450)
* 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.
2024-02-05 21:41:28 -08:00
Antonio e2ff38d170
Support PGAPPNAME (#1444)
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.
2023-12-08 20:21:28 -08:00
Damien Baty f2156b3151
Fix short host (\h) display in prompt when using an IP address (#1441)
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.
2023-11-17 22:38:50 -08:00
Hollis Wu 89979a9353
Fix changelog date (#1438)
* Fix changelog date

* Add my name to authors
2023-11-08 17:07:21 -08:00
Damien Baty 5050f01abc
pgclirc: Clarify description of `destructive_warning_restarts_connection` option (#1437) 2023-11-06 14:10:47 +08:00
Irina Truong 04ca41a262 Releasing version 4.0.1 2023-10-30 20:34:14 -07:00
Irina Truong 525487c36a
Release the pendulum unbump. (#1435) 2023-10-30 10:18:09 +08:00
Dick Marinus 08cf5e720f
downgrade pendulum to released version (#1434)
* downgrade pendulum to released version

* install beta version of pendulum for 3.12
2023-10-29 16:04:00 -07:00
Irina Truong 8c72820d7e Fix readme. 2023-10-27 16:14:37 -07:00
Irina Truong c77529e6a1 Releasing version 4.0.0 2023-10-27 16:01:59 -07:00
Irina Truong 461f7dd267
Update changelog before release. (#1432) 2023-10-27 15:55:44 -07:00
Sharon Yogev 0ad3393fa8
confirm_destructive_query: Use confirm rather than prompt (#1410)
* confirm_destructive_query: Use confirm rather than prompt

* Fix tests
2023-10-18 09:25:29 -07:00
ERYoung11 13ca7d2430
fixed #1403, improved comment handling (#1404)
* fixed #1403, improved comment handling

* black + hooks + changelog

---------

Co-authored-by: Irina Truong <i.chernyavska@gmail.com>
2023-10-12 22:28:11 -07:00
Irina Truong 6332e18b48
Drop python 3.7, add 3.12 (#1426)
* 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.
2023-10-11 12:34:59 +08:00
laixintao f157f3f72e
runs test on main branch as well. (#1429)
* 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.
2023-10-07 17:56:08 -07:00
Amjith Ramanujam a8e34be151
Merge pull request #1425 from dbcli/j-bennet/update-black
Update black
2023-10-06 19:51:15 -07:00
Irina Truong f8ef25309b Go back to black 23.3.0 which supports 3.7 2023-10-06 18:16:30 -07:00
Irina Truong 43f24a5338 Newer black requires 3.8. 2023-10-06 17:51:35 -07:00
Irina Truong 4a4de5260c Update black. 2023-10-06 17:46:46 -07:00
Rob Berry 97a1fd6c16
Allow defining a json file with preferred aliases (#1382)
* 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>
2023-10-06 16:13:28 -07:00
ERYoung11 43360b5d1b
Added \echo & \qecho for Issue #1335 (#1371)
* Added \echo & \qecho for Issue #1335

* black + changelog updates

* trying to re-kick build process
2023-10-06 15:56:48 -07:00
Amjith Ramanujam a615333686
Merge pull request #1419 from dbcli/j-bennet/maintainer-contact-info
Add maintainer contact info to readme
2023-09-26 22:03:38 -07:00
Irina Truong 44e213022d Add maintainer contact info to readme. 2023-09-26 21:45:55 -07:00
Damien Baty cdfa35830b
Ask for confirmation to quit cli if a transaction is ongoing. (#1400)
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.
2023-09-26 21:36:59 -07:00
blag ed89c154ee
For Python >= 3.11 directly use packaging to compare package versions (#1416)
* For Python >= 3.11 directly use packaging to compare package versions

* Improve prompt-toolkit check to test for feature explicitly
2023-09-12 12:46:34 -07:00
astroshot 69dcceb5f6
Fix sql-insert format emits NULL as 'None' (#1409)
* Sub: Fix issue #1408

Body:
1. Fix issue #1408 sql-insert format emits NULL as 'None';
2. Fix DUAL displays as ""DUAL"";

==== End ====

* Sub: Update changelog.rst

Body:

==== End ====

* Sub: Optimize if logic

Body:

==== End ====
2023-06-23 07:05:58 +02:00
Daniel Kukula 6b868bbfe8
Update pyev.py (#1406)
fix typos
2023-05-25 00:40:11 +02:00
Amjith Ramanujam c2f2f5abb2
Merge pull request #1399 from dbaty/dbaty/remove_python2_support
Remove leftovers of Python 2 support
2023-03-18 11:02:54 -07:00
Damien Baty d8eb8b5b82 Apply black (version 23.1.0) 2023-03-18 14:00:38 +01:00
Damien Baty 1c071770bb Remove leftovers of Python 2 support 2023-03-18 10:22:12 +01:00
Amjith Ramanujam 5e34e0b557
Merge pull request #1397 from dbaty/dbaty/require_transaction_for_destructive_statement
feature: Add config option to require a transaction for destructive statements
2023-03-17 19:05:10 -07:00
Damien Baty a93442aed7 lint: Remove unused variables and imported functions 2023-03-08 09:42:43 +01:00
Damien Baty f4dc796941 Add config option to require a transaction for destructive statements
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.
2023-03-08 09:42:43 +01:00
Andy Schoenberger 8ef5392fd1
fix explain output when running with auto-vertical-output or max_width (#1396) 2023-02-27 15:20:59 -08:00
Andy Schoenberger 0a502accfc
add comment to pgclirc pager section on default LESS (#1395) 2023-02-27 14:14:48 -08:00
Andy Schoenberger 141873f86d
Add config option to always run with a single connection (#1386)
Co-authored-by: Irina Truong <i.chernyavska@gmail.com>
2023-01-03 13:52:31 -08:00
Amjith Ramanujam 81b0431d80
Merge pull request #1390 from dbcli/j-bennet/1373-fix-dsn
Fix connecting with dsn.
2023-01-02 15:15:21 -08:00
Irina Truong 7a4086c7c0 Python -m py.test doesn't work anymore. 2023-01-02 15:05:35 -08:00
Irina Truong 4e7bd7cc7a Changelog. 2023-01-02 14:53:08 -08:00
Irina Truong 87d9b2da77 Fix connecting with dsn. 2023-01-02 14:10:29 -08:00
Andy Schoenberger 2db54f14aa
fix psycopg.sql.Identifier in \ev handling (#1384) 2022-11-21 16:10:13 -08:00
Andy Schoenberger d6ca4c3464
Add config option to not automatically restart connection on destructive warning abort; defaults to not restarting. (#1379) 2022-11-17 20:13:05 -08:00
Dick Marinus fa054a5546
add python 3.11 support (#1356)
* add python 3.11 support

* use beta version

* Python 11 is available.

Co-authored-by: Irina Truong <i.chernyavska@gmail.com>
2022-11-11 10:31:41 -08:00
Andy Schoenberger 431c256567
Add config option to not automatically retry connections with operational errors (#1380) 2022-11-11 09:36:41 -08:00
lgtm-com[bot] 2cb6a28f39
Add CodeQL workflow for GitHub code scanning (#1381)
Co-authored-by: LGTM Migrator <lgtm-migrator@users.noreply.github.com>
2022-11-11 09:17:31 -08:00
Anna Glasgall 285e62559e
magic: use pgcli.connect_uri instead of connect (#1375)
This makes %pgcli work even if you use non-password (e.g. TLS cert)
authentication
2022-10-27 17:40:19 -07:00