Bläddra i källkod

Added history persistence (stores 1000 entries)

Stefan Schmidt 6 år sedan
förälder
incheckning
d0fde87998
1 ändrade filer med 8 tillägg och 0 borttagningar
  1. 8 0
      code/ID2TLib/Controller.py

+ 8 - 0
code/ID2TLib/Controller.py

@@ -113,6 +113,11 @@ class Controller:
 
         readline.parse_and_bind('tab: complete')
         readline.set_completer(make_completer(self.statisticsDB.get_all_named_query_keywords()+self.statisticsDB.get_all_sql_query_keywords()))
+        history_file = os.path.join(os.path.expanduser('~'), 'ID2T_data', 'query_history')
+        try:
+            readline.read_history_file(history_file)
+        except IOError:
+            pass
         print("Entering into query mode...")
         print("Enter statement ending by ';' and press ENTER to send query. Exit by sending an empty query..")
         buffer = ""
@@ -130,6 +135,9 @@ class Controller:
                     print("An error occurred:", e.args[0])
                 buffer = ""
 
+        readline.set_history_length(1000)
+        readline.write_history_file(history_file)
+
     def create_statistics_plot(self, params: str):
         """
         Plots the statistics to a file by using the given customization parameters.