mirror of https://github.com/dbcli/pgcli
Add persistent history.
This commit is contained in:
parent
4438cf3376
commit
94b65f8ee9
2
TODO
2
TODO
|
@ -9,5 +9,5 @@
|
|||
* launch psql with -E option and try \d, \dt etc and copy the sql statements.
|
||||
* [ ] Figure out how to deal with transactions.
|
||||
* [ ] Add a lot more SQL keywords to auto-completion.
|
||||
* [ ] Add a history file.
|
||||
* [X] Add a history file.
|
||||
* [ ] Prettify the output into nice columnar tables.
|
||||
|
|
6
pgcli.py
6
pgcli.py
|
@ -2,6 +2,8 @@
|
|||
from __future__ import unicode_literals
|
||||
from __future__ import print_function
|
||||
|
||||
from os.path import expanduser
|
||||
|
||||
import click
|
||||
|
||||
from prompt_toolkit import CommandLineInterface, AbortAction, Exit
|
||||
|
@ -12,6 +14,7 @@ from prompt_toolkit.line import Line
|
|||
from prompt_toolkit.layout import Layout
|
||||
from prompt_toolkit.layout.prompt import DefaultPrompt
|
||||
from prompt_toolkit.layout.menus import CompletionsMenu
|
||||
from prompt_toolkit.history import FileHistory
|
||||
|
||||
from pygments.lexers import SqlLexer
|
||||
|
||||
|
@ -34,7 +37,8 @@ def pgcli(database, user, password, host, port):
|
|||
completer = PGCompleter()
|
||||
completer.extend_keywords(pgexecute.tables())
|
||||
completer.extend_keywords(pgexecute.all_columns())
|
||||
line = Line(completer=completer)
|
||||
line = Line(completer=completer,
|
||||
history=FileHistory(expanduser('~/.pgcli-history')))
|
||||
cli = CommandLineInterface(style=PGStyle, layout=layout, line=line)
|
||||
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue