1
0
Fork 0
Commit Graph

24 Commits

Author SHA1 Message Date
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
Damien Baty d8eb8b5b82 Apply black (version 23.1.0) 2023-03-18 14:00:38 +01:00
Irina Truong e0a4c18c4a
Another attempt to fix pgbouncer error (1093.) (#1097)
* Another attempt to fix pgbouncer error (1093.)

* Fixes for various pgbouncer problems.

* different approach with custom cursor.

* Fix rebase.

* Missed this.

* Fix completion refresher test.

* Black.

* Unused import.

* Changelog.

* Fix race condition in test.

* Switch from is_pgbouncer to more generic is_virtual_database, and duck-type it. Add very dumb unit test for virtual cursor.

* Remove debugger code.
2021-05-21 15:32:34 -07:00
Miroslav Šedivý 762fb4b8da
Modernize code to Python 3.6+ (#1229)
1. `class A(object)` can be written as `class A:`
2. replace `dict([…])` and `set([…])` with `{…}`
3. use f-strings or compact `.format`
4. use `yield from` instead of `yield` in a `for` loop
5. import `mock` from `unittest`
6. expect `OSError` instead of `IOError` or `select` error
7. use Python3 defaults for file reading or `super()`
8. remove redundant parenthesis (keep those in tuples though)
9. shorten set intersection instead of creating lists
10. backslashes in strings do not have to be escaped if prepended with `r`
2021-02-12 21:34:56 +02:00
g.denis 0f3d4602ef
Fix: Unable to drop previously connected-to database (#1152)
* close connections + added to authors + changelog

* check conn exists
2020-03-12 13:45:59 -07:00
Irina Truong 8cb7009bcd
black all the things. (#1049)
* added black to develop guide

* no need for pep8radius.

* changelog.

* Add pre-commit checkbox.

* Add pre-commit to dev reqs.

* Add pyproject.toml for black.

* Pre-commit config.

* Add black to travis and dev reqs.

* Install and run black in travis.

* Remove black from dev reqs.

* Lower black target version.

* Re-format with black.
2019-05-25 13:08:56 -07:00
Irina Truong 33dbb602de Fix crash when using --single-connection. 2019-03-04 16:09:12 -08:00
Mikhail Elovskikh f614cef7ed Support multihost connection string (#978)
* Switch to psycopg2 parse_dsn instead of urlparse

* Added wronglink to contributors and updated changelog

* Fix test codestyle

* Support for PGPORT customization in tests

* Support for PGPORT customization in tests

* Refactored PGExecute init and moved short_host generation to object property

* Fix test util codestyle

* Fix local tests run

* Store PGExecute initial params in  _conn_params and added PGExecute.copy method

* Fix codestyle

* Added docstring to PGExecute.copy() method
2019-01-03 14:27:47 -08:00
Irina Truong 392491a74d
Cherry-picked prompt-toolkit 2.0 changes. (#930)
* Cherry-picked prompt-toolkit 2.0 changes.

* Increase help timeout.

* Missed one.

* Fixes editor command.

* Expect exact to fix named query error.

* Unicode is non-optional with ptk 2.0.

* Unicode literals all the things (almost).

* PEP8.

* Change how we swap completers.

* By default, bottom toolbar styles are reversed. We don't want that.

* Adapt styles to 2.0.

* The future is now. Switch to ptk 2.0 style names.

* PEP8.

* Flag for enable_open_in_editor.

* add class:prompt to prompt

* Removed workaround for #668. Some renaming.

* use pgcli.completer instead of app.current_buffer.completer

* enable_system_prompt=True like old prompt toolkit

* keep search_ignore_case enabled (was ignore_case)

* fix closing parenthese

* keep marking class:continuation token for continuation

* capture KeyboardInterrupt manually

AbortAction has been removed in Prompt_toolkit 2.0

* replace C-J with enter, add more comments

* reversed ([...]) to [(...)] (oops)

* pep8 fixes

* Does Vi mode have to be applied to session every time?

* (workaround) also enable vi_mode after edit command

* Fixed test errors after rebasing on master.
2018-09-28 14:18:40 -07:00
Andrew Speed 82d84ec89f Remove OrderedDict workaround for python < 2.7 2017-08-20 14:46:45 +01:00
Joakim Koljonen f355c30ef7
Include arguments in function completions
E.g. instead of suggesting `my_func()`, suggest `my_func(arg1 :=, arg2 :=)`
or `my_func(arg1 text, arg2 bigint)`, depending on the context.
2017-06-25 01:35:22 +02:00
Étienne BERSAC e124c03575
Fix PEP8 empty line errors 2017-06-14 18:12:05 +02:00
Alexander Schmolck 0c729909cd Make it possible to use SSL with pgcli
This adds support for additional url query params which make stuff like

```
pgcli "postgres://user:pass@host.invalid/db?\
sslmode=verify-full&sslcert=my.pem&sslkey=my-key.pem&sslrootcert=ca.pem"
```

work. More generally it allows one to pass through various extra connection
options.
2017-05-25 14:49:30 +01:00
Joakim Koljonen 9fa429fc1b
Add command-line option --single-connection
This option makes it so that the executor and the completer use the same database connection. This is needed for the completer to function when using one-time passwords for connecting to the database.
2016-07-29 13:54:16 +02:00
koljonen 7e45e893ca
Custom casing of table/column/function/view names
This adds support for defining the casing to be used in completions (for unquoted names). The casing is determined by the casing file, which consists of a \n-separated list of names using the preferred casing. This file can either be populated manually or created automatically (based on usage in SQL/PLPGSQL functions), with a config setting.
2016-06-04 23:05:32 +02:00
koljonen 1626f28b69
Pass around a settings dict instead of the config object 2016-06-02 00:41:14 +02:00
koljonen 740085dd23
Order columns by in-table order when expanding *
And add a setting to use alphabetic order instead.
We simply get the columns from the database in the canonical order, and then sort them if the user has opted for alphabetic order.
2016-05-31 01:29:44 +02:00
koljonen 8431b32166
Support for join-condition suggestions after ON
The user types 'SELECT * FROM parenttable p JOIN childtable c on '. We then suggest ['c.parenttableid = p.parenttableid', 'c.createdby = p.createdby', ...] as completions.
The suggestions are FK matches first, then name matches for int columns, then name matches for other columns, sorted by proximity from the cursor to the other table.

Some changes:
    For "JOIN Foo USING(<cursor>)", now only columns present in Foo are suggested.
    For all suggestions after 'ON', now only the tables before the cursor are considered.
    meta[reltype]][relname] goes from being a list of columns to being an OrderedDict {column_name:ColumnMetadata}, where the ColumnMetaData contains the column's name, data type and a list of FKs involving the column. This entails modification of a number of functions dealing with columns.
2016-05-24 14:18:19 +02:00
Darik Gamble 886b048af0 PGCompleter initializes a prevalence counter (not used yet) 2015-11-08 15:55:49 -05:00
Darik Gamble 7ade315d36 Print refreshing in toolbar 2015-09-06 07:39:33 -04:00
Amjith Ramanujam c9262adf5e Document callbacks, rename restart_completion and cleanup. 2015-09-05 08:11:12 -07:00
Amjith Ramanujam 705d7e0c49 Fix a race condition. 2015-09-03 22:53:06 -07:00
Amjith Ramanujam 43494a0995 Add a ordered dict to the packages for python 2.6 compatibility. 2015-09-03 22:43:50 -07:00
Amjith Ramanujam b8d2b2a258 Add a CompletionRefresher class. 2015-09-03 22:37:31 -07:00