Out of the box, the platform comes with the data connectors for 30+ popular databases, and the list is constantly growing. In addition to that, it is possible to develop your own data connectors, and seamlessly integrate them into the platform.
A server works with the "Grok Connect" REST endpoints registered with the platform. The endpoint's methods are:
getConnectors
- returns all connectors that the endpoint supports (one for database type)getSchema(connection)
- if applicable, returns database schema for the given connectiontestConnection(connection)
- tests the connectionexecute(query)
- executes the specified queryqueryTable(structuredQuery)
- executes a structured query
At startup, the server asks each registered endpoint for the list of supported connectors, and creates a global list of supported connectors. The client asks the server for the available connectors, and populates the UI accordingly. Later on, when client makes a request to query a database, this request gets accepted by a server, and then routed to the corresponding database connector.
-
Create a DataProvider subclass. If you are adding a JDBC provider, subclass it from the JdbcDataProvider.
-
Then, override the required methods depending on the specifics of the database/provider.
-
Add it to the
Providers
list (list of supported providers) in theconnectors_info/DataProvider.java
.
You have two options for testing your database connector:
Test with GrokConnectShell
:
- Open
connectors/examples/query.json
(or use another file which you will need to use in below configuration) and set the query information: set the query itself, datasource equal todescriptor.type
in your provider, credentials to server and server address, port, and db name. - Add next run configuration:
Application
, program arguments:--q examples/query.json --o examples/output.csv
if you want to save your output in theconnectors/examples/output.csv
, or--q examples/query.json
if you want to print your output. - Now you can run
GrokConnectShell.main()
with the added configuration and check the output.
Or you can try to connect Datagrok Docker image to the grok_connect
.