Connect to DB

By connecting to a database, you can directly retrieve data processed in Python from SQL.

1

Create an SQL Connection

Create an SQL Connection from the “Data” tab in the workspace.

2

Obtain the Connection Name of the SQL Connection

Once created successfully, you can obtain the connection name from the list display.

3

Create an SQL File and Retrieve Data

Create an SQL file and retrieve data.

{{
  config(
    connection="connection_name"
  )
}}

select * from table_name;

Connecting to SaaS

SaaS connections are only available in the cloud version.

Morph provides integration with some SaaS services. By using these integrations, you can delegate all authentication implementations to Morph and focus on implementing business logic.

Here is how to obtain an access_token from an Integration created in Python.

import pandas as pd

import morph
from morph import MorphGlobalContext
from morph_lib.api import get_auth_token

@morph.func
def get_salesforce_opportunities(context: MorphGlobalContext) -> pd.DataFrame:
    access_token = get_auth_token("salesforce-connection-name")

    # ↓↓↓ call API with access_token ↓↓↓