#!/bin/sh

# Convert Databricks JDBC URL to ODBC Connection String
# Copyright 2024 Stelo

# This is a simple script that can be run on Linux or any UNIX-like environment that includes sed
# to convert the JDBC URL displayed in Databricks to an ODBC connection string
# that can be entered when creating an SQDR source or destination in Data Replicator Manager (Tier 3).

# It assumes that the format of the string will not change and does no error checking.
# After removing jdbc:databricks://, the first colon should be before the port
# and the first slash it will encounter demarks the database name.

echo Enter the JDBC URL as displayed in Databricks in
echo "the JDBC/ODBC tab in Advanced Options of the Compute Cluster:"
echo
read line
echo
echo Use this as an SQDR connection string for the Simba Spark driver:
echo
echo $line | sed \
-e s,'UID=token;PWD=<personal-access-token>',, \
-e s,'jdbc:databricks://','host=', \
-e s,':',';port=', \
-e s,'/',';Database=', \
-e s,'transportMode=http','ThriftTransport=2',


