Forum Discussion

Elmo22's avatar
Elmo22
Frequent Visitor
2 years ago
Solved

changing datasource and changing sttings for each query

Hi All 

Should I change the sittings for each query when changing the data source?

or there is a way changing the data source sittings from datasource sittings only


  • Elmo22 wrote:

    Hi All 

    Should I change the sittings for each query when changing the data source? dollartree-compass.com

    or there is a way changing the data source sittings from datasource sittings only


     

    Hello, Elmo22 

     

    To change the data source for your queries efficiently:

    Update Data Source Settings:
    If the schema is the same, update the connection details in your data source settings. This will apply to all queries automatically.
    Adjust Queries Individually:
    If the schema is different, you need to update each query to match the new data source structure.
    Steps:
    SQL Clients/BI Tools:
    Open your tool (e.g., SQL client, Tableau, Power BI).
    Navigate to Data Source/Connection settings.
    Update the connection details (server, database, credentials).
    Save and refresh.
    Code Example (Python with SQLAlchemy):

     

    # Update connection string
    new_connection_string = 'mysql+pymysql://user:password@new_host/new_db'
    engine = create_engine(new_connection_string)
    connection = engine.connect()
    result = connection.execute("SELECT * FROM my_table")

     

    Consistent Schema: Change connection settings only.
    Different Schema: Update each query as needed.
    Test your queries after making changes to ensure they work with the new data source.

     

     

    I hope this step is helpful for you.

     

    Best Regard,
    nicholas185

1 Reply


  • Elmo22 wrote:

    Hi All 

    Should I change the sittings for each query when changing the data source? dollartree-compass.com

    or there is a way changing the data source sittings from datasource sittings only


     

    Hello, Elmo22 

     

    To change the data source for your queries efficiently:

    Update Data Source Settings:
    If the schema is the same, update the connection details in your data source settings. This will apply to all queries automatically.
    Adjust Queries Individually:
    If the schema is different, you need to update each query to match the new data source structure.
    Steps:
    SQL Clients/BI Tools:
    Open your tool (e.g., SQL client, Tableau, Power BI).
    Navigate to Data Source/Connection settings.
    Update the connection details (server, database, credentials).
    Save and refresh.
    Code Example (Python with SQLAlchemy):

     

    # Update connection string
    new_connection_string = 'mysql+pymysql://user:password@new_host/new_db'
    engine = create_engine(new_connection_string)
    connection = engine.connect()
    result = connection.execute("SELECT * FROM my_table")

     

    Consistent Schema: Change connection settings only.
    Different Schema: Update each query as needed.
    Test your queries after making changes to ensure they work with the new data source.

     

     

    I hope this step is helpful for you.

     

    Best Regard,
    nicholas185