Dss connection has no attribute cursor.
Hi Team,
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 Attribute error ::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.
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,215 Dataiker
HI @Obireddy
,
Can you try to print connection_handle?
It should return -> <dataikuapi.dss.admin.DSSConnection object at 0x7f6326340040>You seem to be using a cursor attribute later, which does not exist for this object.
In this instance, you would need to retrieve the params you need dssclient.get_connection().get_info() check the connection attributes and pass these individually to your sqlite. Given the user has sufficient permission to read the connection information.
However, DSS provides SQLExecutor2 which should work in this case where you can just pass the connection name.
https://knowledge.dataiku.com/latest/code/python/tutorial-sql-in-python-recipe.html
I would suggest you use SQLExecutor2 instead of sqllite .Thanks