Dataiku session metadata

I'm looking to setup a global instance variable for all users as a type of default when using a specific database connection. As part of the variable creation, I would like to pull in their Dataiku login information to help build the value. This is because in the backend database, each user has a role name: <dataiku login>_role.
So in the global variables section, I would see it looking something like this:
{
"database_role": <dataiku login variable>"_ROLE"
}
The problem is I cannot find how to access Dataiku session metadata. I searched around documentation for a bit but cannot seem to find it. Ideas?
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,271 Dataiker
Hi @msucrah
,Would be able to clarify which database you would be using?
For snowflake for example something like this could be possible by setting the role to ${userProperty:database_role} as explained here.
https://doc.dataiku.com/dss/latest/connecting/sql/snowflake.html
This would mean each user would need to have userProperty set to the
{ "database_role": "<replace_username>_ROLE" }
You add this for every user via the API :
import dataiku client = dataiku.api_client() dss_users = client.list_users() for i in dss_users: username = i['login'] settings = user.get_settings() settings.user_properties["database_role"] = username+"_ROLE" settings.save()