dbcli / pgcli

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

[help] Autocomplete for extension's functions? #1180

Open tobwen opened 4 years ago

tobwen commented 4 years ago

Description

I've installed extension PostGIS, but cannot autocomplete its functions. Is this possible at all?

Your environment

pgcli --version

Version: 3.0.0 - build bcb0c8bce776a5eba9f5425c57c2ec8385f10e94

system

Debian Buster with latest updates, Kernel 5.4.0-0.bpo.4-amd64

dpkg --list | grep postgresql

ii  pgdg-keyring                           2018.2                                           all          keyring for apt.postgresql.org
ii  postgresql-12                          12.2-2.pgdg100+1                                 amd64        object-relational SQL database, version 12 server
ii  postgresql-12-pgmp                     1.0.4-2.pgdg100+1                                amd64        arbitrary precision integers and rationals for PostgreSQL 12
ii  postgresql-12-postgis-3                3.1.0~alpha1+dfsg-1~exp3                         amd64        Geographic objects support for PostgreSQL 12
ii  postgresql-12-postgis-3-dbgsym         3.1.0~alpha1+dfsg-1~exp3                         amd64        debug symbols for postgresql-12-postgis-3
ii  postgresql-12-postgis-3-scripts        3.1.0~alpha1+dfsg-1~exp3                         all          Geographic objects support for PostgreSQL 12 -- SQL scripts
ii  postgresql-12-rational                 0.0.2-1.pgdg100+1                                amd64        Precise fractional arithmetic for PostgreSQL
ii  postgresql-client-12                   12.2-2.pgdg100+1                                 amd64        front-end programs for PostgreSQL 12
ii  postgresql-client-common               215~382.gitb94362a.pgdg100+1                     all          manager for multiple PostgreSQL client versions
ii  postgresql-common                      215~382.gitb94362a.pgdg100+1                     all          PostgreSQL database-cluster manager

pip3 freeze

asn1crypto==0.24.0
atomicwrites==1.1.5
attrs==18.2.0
bottle==0.12.18
certifi==2020.4.5.1
chardet==3.0.4
cli-helpers==1.2.1
click==7.1.1
colorama==0.4.3
conan==1.24.0
configobj==5.0.6
cryptography==2.6.1
deprecation==2.0.7
devscripts===2.20.2-bpo10-1
distro==1.1.0
entrypoints==0.3
fail2ban==0.10.2
fasteners==0.15
future==0.18.2
gpg==1.12.0
humanfriendly==4.18
humanize==2.3.0
idna==2.9
iotop==0.6
Jinja2==2.11.1
keyring==17.1.1
keyrings.alt==3.1.1
MarkupSafe==1.1.1
meson==0.52.1
monotonic==1.5
more-itertools==4.2.0
node-semver==0.6.1
numpy==1.16.2
opencv-python==4.1.2.30
packaging==20.3
patch-ng==1.17.4
pgspecial==1.11.9
pluggy==0.8.0
pluginbase==0.7
prompt-toolkit==3.0.5
psycopg2==2.8.5
py==1.7.0
pycrypto==2.6.1
Pygments==2.6.1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.1
pyparsing==2.4.7
pytest==3.10.1
python-apt==1.8.4.1
python-dateutil==2.8.1
python-debian==0.1.35
python-magic==0.4.16
pyxdg==0.25
PyYAML==5.3.1
requests==2.23.0
SecretStorage==2.3.1
setproctitle==1.1.10
six==1.12.0
sqlparse==0.3.1
systemd-python==234
tabulate==0.8.7
terminaltables==3.1.0
tqdm==4.45.0
unidiff==0.5.4
urllib3==1.25.8
visidata===2.-3
wcwidth==0.1.9

cat ~/.config/pgcli/config (unchanged)

extend me ``` python # vi: ft=dosini [main] # Enables context sensitive auto-completion. If this is disabled the all # possible completions will be listed. smart_completion = True # Display the completions in several columns. (More completions will be # visible.) wider_completion_menu = False # Multi-line mode allows breaking up the sql statements into multiple lines. If # this is set to True, then the end of the statements must have a semi-colon. # If this is set to False then sql statements can't be split into multiple # lines. End of line (return) is considered as the end of the statement. multi_line = False # If multi_line_mode is set to "psql", in multi-line mode, [Enter] will execute # the current input if the input ends in a semicolon. # If multi_line_mode is set to "safe", in multi-line mode, [Enter] will always # insert a newline, and [Esc] [Enter] or [Alt]-[Enter] must be used to execute # a command. multi_line_mode = psql # Destructive warning mode will alert you before executing a sql statement # that may cause harm to the database such as "drop table", "drop database" # or "shutdown". destructive_warning = True # Enables expand mode, which is similar to `\x` in psql. expand = False # Enables auto expand mode, which is similar to `\x auto` in psql. auto_expand = False # If set to True, table suggestions will include a table alias generate_aliases = False # log_file location. # In Unix/Linux: ~/.config/pgcli/log # In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\log # %USERPROFILE% is typically C:\Users\{username} log_file = default # keyword casing preference. Possible values "lower", "upper", "auto" keyword_casing = auto # casing_file location. # In Unix/Linux: ~/.config/pgcli/casing # In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\casing # %USERPROFILE% is typically C:\Users\{username} casing_file = default # If generate_casing_file is set to True and there is no file in the above # location, one will be generated based on usage in SQL/PLPGSQL functions. generate_casing_file = False # Casing of column headers based on the casing_file described above case_column_headers = True # history_file location. # In Unix/Linux: ~/.config/pgcli/history # In Windows: %USERPROFILE%\AppData\Local\dbcli\pgcli\history # %USERPROFILE% is typically C:\Users\{username} history_file = default # Default log level. Possible values: "CRITICAL", "ERROR", "WARNING", "INFO" # and "DEBUG". "NONE" disables logging. log_level = INFO # Order of columns when expanding * to column list # Possible values: "table_order" and "alphabetic" asterisk_column_order = table_order # Whether to qualify with table alias/name when suggesting columns # Possible values: "always", never" and "if_more_than_one_table" qualify_columns = if_more_than_one_table # When no schema is entered, only suggest objects in search_path search_path_filter = False # Default pager. # By default 'PAGER' environment variable is used # pager = less -SRXF # Timing of sql statments and table rendering. timing = True # Table format. Possible values: psql, plain, simple, grid, fancy_grid, pipe, # ascii, double, github, orgtbl, rst, mediawiki, html, latex, latex_booktabs, # textile, moinmoin, jira, vertical, tsv, csv. # Recommended: psql, fancy_grid and grid. table_format = psql # Syntax Style. Possible values: manni, igor, xcode, vim, autumn, vs, rrt, # native, perldoc, borland, tango, emacs, friendly, monokai, paraiso-dark, # colorful, murphy, bw, pastie, paraiso-light, trac, default, fruity syntax_style = default # Keybindings: # When Vi mode is enabled you can use modal editing features offered by Vi in the REPL. # When Vi mode is disabled emacs keybindings such as Ctrl-A for home and Ctrl-E # for end are available in the REPL. vi = False # Error handling # When one of multiple SQL statements causes an error, choose to either # continue executing the remaining statements, or stopping # Possible values "STOP" or "RESUME" on_error = STOP # Set threshold for row limit. Use 0 to disable limiting. row_limit = 1000 # Skip intro on startup and goodbye on exit less_chatty = False # Postgres prompt # \t - Current date and time # \u - Username # \h - Short hostname of the server (up to first '.') # \H - Hostname of the server # \d - Database name # \p - Database port # \i - Postgres PID # \# - "@" sign if logged in as superuser, '>' in other case # \n - Newline # \dsn_alias - name of dsn alias if -D option is used (empty otherwise) # \x1b[...m - insert ANSI escape sequence # eg: prompt = '\x1b[35m\u@\x1b[32m\h:\x1b[36m\d>' prompt = '\u@\h:\d> ' # Number of lines to reserve for the suggestion menu min_num_menu_lines = 4 # Character used to left pad multi-line queries to match the prompt size. multiline_continuation_char = '' # The string used in place of a null value. null_string = '' # manage pager on startup enable_pager = True # Use keyring to automatically save and load password in a secure manner keyring = True # Custom colors for the completion menu, toolbar, etc. [colors] completion-menu.completion.current = 'bg:#ffffff #000000' completion-menu.completion = 'bg:#008888 #ffffff' completion-menu.meta.completion.current = 'bg:#44aaaa #000000' completion-menu.meta.completion = 'bg:#448888 #ffffff' completion-menu.multi-column-meta = 'bg:#aaffff #000000' scrollbar.arrow = 'bg:#003333' scrollbar = 'bg:#00aaaa' selected = '#ffffff bg:#6666aa' search = '#ffffff bg:#4444aa' search.current = '#ffffff bg:#44aa44' bottom-toolbar = 'bg:#222222 #aaaaaa' bottom-toolbar.off = 'bg:#222222 #888888' bottom-toolbar.on = 'bg:#222222 #ffffff' search-toolbar = 'noinherit bold' search-toolbar.text = 'nobold' system-toolbar = 'noinherit bold' arg-toolbar = 'noinherit bold' arg-toolbar.text = 'nobold' bottom-toolbar.transaction.valid = 'bg:#222222 #00ff5f bold' bottom-toolbar.transaction.failed = 'bg:#222222 #ff005f bold' # style classes for colored table output output.header = "#00ff5f bold" output.odd-row = "" output.even-row = "" # Named queries are queries you can execute by name. [named queries] # DSN to call by -D option [alias_dsn] # example_dsn = postgresql://[user[:password]@][netloc][:port][/dbname] # Format for number representation # for decimal "d" - 12345678, ",d" - 12,345,678 # for float "g" - 123456.78, ",g" - 123,456.78 [data_formats] decimal = "" float = "" ```
amjith commented 3 years ago

Are the PostGIS functions scoped under a schema? If so, you will have to qualify your query with the schema name.

SELECT * FROM schema.func_name

Alternatively, I just merged a PR #1266 to include functions from a schema that is present in the search_path. You can install directly from master and give it a shot.

pip install -U https://github.com/dbcli/pgcli/archive/refs/heads/master.zip