diff options
author | François Pietka <francois@pietka.fr> | 2017-08-02 08:47:18 +0200 |
---|---|---|
committer | François Pietka <francois@pietka.fr> | 2017-08-12 13:03:28 +0200 |
commit | 727a123429318a97eb6e987ca3ce91ec4e9c1bf2 (patch) | |
tree | 0bb6ef9ea26cb46d86d188ac636c3e74c1974c25 | |
parent | 9c0304df1fb921eca652ce4e84a5c99fbbded4a2 (diff) |
Add \conninfo command
-rwxr-xr-x | pgcli/main.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pgcli/main.py b/pgcli/main.py index 45149f8f..67834c75 100755 --- a/pgcli/main.py +++ b/pgcli/main.py @@ -203,6 +203,20 @@ class PGCli(object): 'Execute commands from file.') self.pgspecial.register(self.write_to_file, '\\o', '\\o [filename]', 'Send all query results to file.') + self.pgspecial.register(self.info_connection, '\\conninfo', + '\\conninfo', 'Get connection details') + + def info_connection(self, **_): + if self.pgexecute.host.startswith('/'): + host = 'socket "%s"' % self.pgexecute.host + else: + host = 'host "%s"' % self.pgexecute.host + + yield (None, None, None, 'You are connected to database "%s" as user ' + '"%s" on %s at port "%s".' % (self.pgexecute.dbname, + self.pgexecute.user, + host, + self.pgexecute.port)) def change_db(self, pattern, **_): if pattern: |