Get back query text from reult tab?


Lot of times I run query, pin result, modify, pin, modify pin....

I can see the query text when I hover over the tabs.   I don't have it in my editor anymore.  Can I get it back?

I do know about the amazing local history feature . . . it would be cool if hovering over the tab with previous query hyperlinked back to local history, or let you create a label in local history.

I'm using Datagrip in pycharm.


in datagrip, the query history is stored in the Local History feature, which allows you to track and manage the changes you make to your files. However, the specific functionality you mentioned, where hovering over a tab with a previous query would hyperlink back to the local history or create a label, is not a built-in feature in DataGrip.

To access the query text from previous queries, you can use the Local History feature directly. Here's how you can do it:

  1. In DataGrip, open the "Database" tool window.
  2. In the tool window, locate the "Local History" tab.
  3. Click on the "Local History" tab to expand it and see the list of changes.
  4. Look for the relevant query or file change in the list and click on it to view its contents.
  5. The query text or file contents will be displayed in the main editor area.

You can then copy the query text and use it as needed. Unfortunately, there is no direct hyperlink between the query tabs and the Local History feature in DataGrip.

If you find yourself frequently modifying and pinning queries, another option you can consider is creating separate scratch files in DataGrip. Scratch files allow you to create and modify temporary files without having to associate them with a specific project or file. You can easily access and manage scratch files from the "Scratches and Consoles" tool window.

To create a scratch file in DataGrip, you can follow these steps:

  1. Go to "View" in the menu bar.
  2. Navigate to "Tool Windows" and select "Scratches and Consoles".
  3. In the "Scratches and Consoles" tool window, click on the "+" button to create a new scratch file.
  4. Enter your query or code in the scratch file.
  5. You can then modify and pin the scratch file as needed.

Using scratch files can provide a more flexible way to manage and modify your queries without affecting your original files or relying solely on the query history.

I hope this helps! Let me know if you have any further questions.


Yes, thank you, it helps.


Levin, also take a loot at View Query and Jump to Source actions that can restore your original query


vasily chernov -

Sorry if this is a dupe...

"View Query" from the cog dropdown shows me the text I want to edit, but it is not selectable.

The menu choice immediately below that, "Copy query to console" sounds like just what I want. DataGrip in #PY-231.9011.38, that "Copy query to console" doesn't do anything as far as I can tell.



What DataGrip version do you work with? Since I can't reproduce with the latest one.


Please sign in to leave a comment.