I want to configure databricks-connect configure
through python OS module after installing databricks-connect through os.system("pip install databricks-connect==6.5")
Once databricks-connect is successfully install we need to configure it by passing the following values:
host= "https://<location>.azuredatabricks.net",
port= "8787",
token = "<Token>",
cluster_id = "<ClusterId>",
org_id = "<OrgId>"
In the terminal if we type databricks-connect configure
, it will start asking you above parameter one by one as shown in the figure:
Now I want same thing to be run using python os.system
os.system("pip install databricks-connect")
os.system("databricks-connect configure")
After this how to pass host, port, token etc.?
After every value we have to press enter
as well.
when I run this on terminal this work fine ,
echo -e 'https://adb-661130381327abc.11.azuredatabricks.net\nxxxxx\n0529-yyyy-twins608\n6611303813275431\n15001' | databricks-connect configure
but giving me error when i try to run this python os.module
os.sytem("echo -e 'https://adb-661130381327abc.11.azuredatabricks.net\nxxxxx\n0529-yyyy-twins608\n6611303813275431\n15001' | databricks-connect configure")
Error "New host value must start with https://, e.g., https://demo.cloud.databricks.com")
A small modification to @Anmol
import subprocess
host= "https://<location>.azuredatabricks.net"
port= "8787"
token = "<Token>"
cluster_id = "<ClusterId>"
org_id = "<OrgId>"
stdin_list = [host, port, token, cluster_id, org_id]
stdin_string = '\n'.join(stdin_list)
echo = subprocess.Popen((['echo', '-e', stdin_string]), stdout=subprocess.PIPE)
# fix typo from std_out to stdout
output = subprocess.check_output(('databricks-connect', 'configure'), stdin=echo.stdout)
echo.wait()
print(output.decode())
echo -e
takes care of the enter