Retrieve the Database connection details in python notebook.
Hi Team,
As of now, Presto connection established in Dataiku to access from Database. but how can we retrieve those connection details into jupyter notebooks as variables to use them for making another connections.
Thanks in Advance.
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,043 Neuron
I am not really sure what you are trying to achieve here so can you please describe your requirement properly? If you have a Dataiku connection then you would normally create datasets from that connection on the flow and then create recipes that update those datasets. Then on a Jupyter Notebook you can access these datasets.
-
Hi,
Let me explain the problem clearly,
1)We have presto connection to access Database by providing all required details.
2)Able to create datasets and load data from database.
3)now want to retrieve the presto connection details like credentials and port number and host details in jupyter notebook for another purpose.
will it be possible ?
Thanks in advance.
regards,
Obireddy
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,043 Neuron
will it be possible? Yes!
for another purpose => What purpose? As that can change how you get the details. -
another purpose means, want to invoke external(API/DB) connection with same Presto connection details.
like conn=api.connect(host= ,port= ,auth=(user,password)
cur=conn.cursor()
here in conn() host, port ,auth details need to same as Presto connection details.
So how can I fetch those details into jupyter notebook or python recipe ?
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,043 Neuron
Yeah this should do it:
import dataiku client = dataiku.api_client() connection_handle = client.get_connection('some_connection_name') connection_definition = connection_handle.get_definition() print(connection_definition)
-
Thank you. I am able to fetch Presto connection details in Jupyter notebook.
But when I try to invoke API connection using same Presto details, getting error as Dss connection has no attribute cursor.
my code as below:
import dataiku
client=dataiku.api_client()
connection_handle=client.get_connection('my_connection')
import sqlite
conn=(provided all details from connection_handle)
conn.cursor() #here I am getting error like Dss connection has no attribute cursor.
So how can we make cursor() available for Dataiku to interact with other connections?
or can we make any changes to existing Presto connection which also enable cursor() functionality?
Please suggest.
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,043 Neuron
Please:
- Please post your actual code (you can replace any secret data with xxx or whatever
- Please post the full error with the full stsck trace
- Please use a Code section in your post so the code is correctly formatted (look for the </> icon when writting the post)
Thanks