Question

Dynamic connection string

  • 16 March 2023
  • 6 replies
  • 31 views

 

Hi, is there a way to give the connection string in a dynamic way?

for example, I tried creating a constant with the user attributes, but i cannot use this constant in the connection of the model


6 replies

Userlevel 7
Badge

No not possible, you can either make the connection dynamic via a user attribute (in some attributes of the connection) or you can extend explores from new models that use other connections.

could you elaborate a bit on the second option?

i want to change the connection based on the instance im in. in each instance i have a user_attribute to check in which instance i am. 

hi could you elaborate on the second solution?>

No not possible, you can either make the connection dynamic via a user attribute (in some attributes of the connection) or you can extend explores from new models that use other connections.

 

Hi,

The correct way to do what you want to do is to create a project per instance, import the LookML base project and override the constant that holds the connection string.

https://cloud.google.com/looker/docs/importing-projects

 

Hope this helps.

 

Hi,

The correct way to do what you want to do is to create a project per instance, import the LookML base project and override the constant that holds the connection string.

https://cloud.google.com/looker/docs/importing-projects

 

Hope this helps.

 

thanks for answering. the problem is a constant cannot be used for a connection string (when defining a model you write connection: "connection_name”. you cannot use a constant here

Hi,

The correct way to do what you want to do is to create a project per instance, import the LookML base project and override the constant that holds the connection string.

https://cloud.google.com/looker/docs/importing-projects

 

Hope this helps.

 

thanks for answering. the problem is a constant cannot be used for a connection string (when defining a model you write connection: "connection_name”. you cannot use a constant here

 

That’s is not correct. A constant can be used for a connection string. This works fine:

manifest.lkml
constant: db_connection { value: "paris_db"}

project.model
connection: "@{db_connection}"

 

Reply