Export to JSON unavailable

Answered

Recently moved my DataGrip installation to a new PC and in the process installed the latest version (DataGrip 2022.3.3
Build #DB-223.8617.3, built on January 10, 2023).

I find that I am now no longer able to export data in JSON format, only as CSV, TSV, pipe-separated types.

It would appear that the JSON data extractor is no longer available.

Any ideas on how I can retrieve the export as JSON format back again?

 

0
9 comments

Below find the contents of the JSON-Groovy.json.groovy extractor that I have.

Filename:  JSON-Groovy.json.groovy
Location: C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3\extensions\com.intellij.database\data\extractors

/*
 * Available context bindings:
 *   COLUMNS     List<DataColumn>
 *   ROWS        Iterable<DataRow>
 *   OUT         { append() }
 *   FORMATTER   { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); }
 *   TRANSPOSED  Boolean
 * plus ALL_COLUMNS, TABLE, DIALECT
 *
 * where:
 *   DataRow     { rowNumber(); first(); last(); data(): List<Object>; value(column): Object }
 *   DataColumn  { columnNumber(), name() }
 */


import static com.intellij.openapi.util.text.StringUtil.escapeStringCharacters as escapeStr

NEWLINE = System.getProperty("line.separator")
INDENT = "  "

def printJSON(level, col, o) {
  switch (o) {
    case null: OUT.append("null"); break
    case Tuple: printJSON(level, o[0], o[1]); break
    case Map:
      OUT.append("{")
      o.entrySet().eachWithIndex { entry, i ->
        OUT.append("${i > 0 ? "," : ""}$NEWLINE${INDENT * (level + 1)}")
        OUT.append("\"${escapeStr(entry.getKey().toString())}\"")
        OUT.append(": ")
        printJSON(level + 1, col, entry.getValue())
      }
      OUT.append("$NEWLINE${INDENT * level}}")
      break
    case Object[]:
    case Iterable:
      OUT.append("[")
      def plain = true
      o.eachWithIndex { item, i ->
        plain = item == null || item instanceof Number || item instanceof Boolean || item instanceof String
        if (plain) {
          OUT.append(i > 0 ? ", " : "")
        }
        else {
          OUT.append("${i > 0 ? "," : ""}$NEWLINE${INDENT * (level + 1)}")
        }
        printJSON(level + 1, col, item)
      }
      if (plain) OUT.append("]") else OUT.append("$NEWLINE${INDENT * level}]")
      break
    case Boolean: OUT.append("$o"); break
    default:
      def str = FORMATTER.formatValue(o, col)
      def typeName = FORMATTER.getTypeName(o, col)
      def shouldQuote = FORMATTER.isStringLiteral(o, col) && !(typeName.equalsIgnoreCase("json") || typeName.equalsIgnoreCase("jsonb"))
      OUT.append(shouldQuote ? "\"${escapeStr(str)}\"" : str);
      break
  }
}

printJSON(0, null, ROWS.transform { row ->
  def map = new LinkedHashMap<String, String>()
  COLUMNS.each { col ->
    if (row.hasValue(col)) {
      def val = row.value(col)
      map.put(col.name(), new Tuple(col, val))
    }
  }
  map
})
0

Hello,

Please check that extractor mentioned above exists on your machine.

0

It would appear that my installation is missing some directories.

All I have is C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3\extensions\com.intellij.database\schema (which is empty)

There isn't even a C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3\extensions\com.intellij.database\data directory, let alone C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3\extensions\com.intellij.database\data\extractors

0

Please try to reinstall IDE. 

0

Hi,

Just tried the following steps

  1. Uninstalled using Toolbox.
  2. Restarted PC.
  3. Installed using Toolbox.
  4. Started DataGrip - left selection of configuration file to import to default option - no file selected.
  5. Added connection to SQL Server and installed drivers.
  6. Read table and selected to export data.

Result - no option to export in JSON format only CSV.

Checking C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3 there's not even an extensions directory.

I think that I'm going to have to find a working installation of DataGrip and copy the relevant directories and files. 

0

Are there other folders in "C:\Users\<user>\AppData\Roaming\JetBrains\DataGrip2022.3"? Please check that folder is empty after uninstallation and remove it manually before installation.

0

Okay.

I've looked further.

It would appear that installation of DataGrip places files in c:\Users\<user>\AppData\Local\Jetbrains\DataGrip2022.3 as well as C:\Users\<user>\AppData\Roaming\Jetbrains\DataGrip2022.3

Deleting files from just the Roaming profile prevented DataGrip from installing the extra directories required for the JSON data extractor.

Having uninstalled DataGrip, deleted DataGrip2022.3 directories and sub files from BOTH Local and Roaming and then reinstalled it now wiorks.

I noted that the additional directories in Roaming that contain the data extractors are installed when I select to export data.

Thank you for your help.

1

Cbd

Thank you for that update!  I tried to install DG by uninstalling the previous version and installing the new one after a reboot.  That didn't go well because I couldn't connect to my Oracle db after re-install.  I am using Kerberos authentication.  Only after I restored the old folders was I able to log in.  Perhaps I will follow your lead and make sure more sneaky DG user folders are removed first.

0

Make sure that the inside the Scratches and Consoles folder contains the following:

  • Database Tools and SQL -> data -> aggregators | extractors

 

 

0

Please sign in to leave a comment.