What objects/functions are available for custom data extractors? Follow
Is there any documentation on these objects?
What methods are available on them?
Are there other objects that are available?
Please sign in to leave a comment.
This API is experimental, it is not published yet, and it is subject to change.
But here is some overview on what there is:
Exposes default formatting methods:
java.lang.String format(com.intellij.database.extractors.DataRow, com.intellij.database.extractors.DataColumn);
java.lang.String format(java.lang.Object, com.intellij.database.extractors.DataColumn);
Row data stream.
I hope, it helps. Feel free to ask questions and share your ideas on how to improve this feature.
In the 2020.3 release, the documentation in the extractor header was updated to add getTypeName and isStringLiteral.
getTypeName(object, col) will return the datatype of a column as reported from the db. Although row and column are required here from what I can tell this is the datatype of the column not of the row. If you're using SQLite null column with multiple datatypes the info from the first row will be returned.
I use Oracle 12c, SQL Server, and SQLite. Below are datatypes I extracted from my db.
Here is an example of usage from my MERGE extractor:
isStringLiteral(object, col) will return a boolean indicating the field is a string datatype. This came about due to false-positive when trying to identify numeric fields. Before we had to convert to a string then check to see if that string was a number resulting in account number fields being converted.
Starting with the 1.0 Public Preview build, we're shipping sources for open API parts of the product.
They can be found in %IDE_HOME%/lib/src/src_database-openapi.zip.
Is the source code or API of those com.intellij.database.* classes (like com.intellij.database.model.DasTable) available somewhere?
Not yet, but they will become a part of public API, too.
Until then, if you need help figuring out something - just ask, and we'll try to help you.
BTW, what kind of extractor are you trying to build?
Currently I'm building an extractor that will provide data for our DB test runner, on the form
- which I just now succeeded in doing, thanks to TABLE.name. Thanks!
Previously I wrote an extractor that outputs the resultset in JIRA markup table format:
I'll post the code for the JIRA extractor here, in case it can help anyone:
Date formatting will probably be an issue soon.
Where does FORMATTER get its date format from, when formatting an Oracle DATE value, for example?
For now, it doesn't do anything clever - it just uses "yyyy-MM-dd HH:mm:ss" for timestamps, "yyyy-MM-dd" for dates, and "HH:mm:ss" for times.
So you may want to use the instanceof operator to dispatch on value types and format them the way you want.
If anyone is interested: I've written a MySQL like output format the other day. For small datasets it makes it easy to communicate the values using fixed width font:
You can find it here https://github.com/aukevanleeuwen/intellij-extractors
@Sergey Savenko thanks, but how to import the package?
Unfortunately, %IDE_HOME%/lib/src/src_database-openapi.zip was included in datagrip-2016.1.exe, but is missing in datagrip-2016.3.2.exe and later versions.
And com.intellij.database java sources aren't still published in any googlable place.
When highlighting a sql select statement and using the execute to file/SQL Inserts method, the TABLE object supplied to the extractors is null and all insert statements are using "MY_TABLE" as the table name.
However, when executing the same statement without export, then exporting from the results pane, the table object gets supplied to the sql inserts script and the insert statements are using the correct table name.
Is there a way to get the table name for an extractor when executing to file?
I also notice that when using the same export/extractor method (SQL Inserts), the sql statement case when using the method from the results pane (lower) is different from when applied directly to a sql statement. I feel like this is a clue, but I don't know where to go from here. Thanks!
Howdy, is there a way of dumping multiple tabs or the output of the entire script file to the same out file?
There are two issue that met your description you can vote for:
I am writing a Data Extractor to automatically create a DataFixture for PHP based on a query, it is mostly finished, but I am having some issues with timestamps and want to know the type of the column (to detect timestamp), can you give me a clue please?
I have tried something like this:
I am trying to write an Oracle SQL multireow insert extractor - almost finished, but the last detail is the date columns. Right now I have to mannualy (outside Datagrip) convert "2020-12-16 10:21:11.876990" to "TO_DATE("2020-12-16 10:21", "YYYY-MM-DD HH24:MI:SS")".
I can make a regular expression test to check if it´s a date, but it would be much cleaner if I had the type of the column, that I believe is in the com.intellij.database.extractors.DataColumnImpl, but I can´t find any documentation on the class.
Anyone knows where I can find these docs ?
For ORACLE, and improving slightly on Jim Gust's contribution (thanks Jim!), I did this within a copy of SQL-Insert-Statements.sql.groovy in order to capture a different TO_DATE mask for DATE fields that have only the date and no time.
Is there any update on the location of the documentation for this? It seems strange that this community post is the best source of information on the API.
Thank you for the update. Based on what you did I expanded the Oracle date logic to cover all of the date data types. Below is my SQL-Insert-Statements.sql.groovy
Test table and insert statement generated from SQL-Insert-Statements.sql.groovy
Also, some info mentioned in
But we're working on documentation creation.
The default converters are not suitable for large files, please create avro/parquet/orc file exporters too