Environment

Sling looks for connection credentials in several places:

One of the easiest ways is to manage your connections is to use the sling conns sub-command. Follow in the next section.

Managing Connections

Sling makes it easy to set, list and test connections. You can even see the available streams in a connection by using the discover sub-command.

$ sling conns -h
conns - Manage and interact with local connections

See more details at https://docs.slingdata.io/sling-cli/

  Usage:
    conns [discover|list|set|test]

  Subcommands:
    discover   list available streams in connection
    list       list local connections detected
    test       test a local connection
    unset      remove a connection from the sling env file
    set        set a connection in the sling env file
    exec       execute a SQL query on a Database connection

  Flags:
       --version   Displays the program version string.
    -h --help      Displays help with available flag, subcommand, and positional value parameters.

Set Connections

Here we can easily set a connection with the sling conns set command and later refer to them by their name. This ensures credentials are not visible by other users when using process monitors, for example.

To see what credential keys are necessary/accepted for each type of connector, click below:

  • File/Storage Connections (see here)

  • Database Connections (see here)

List Connections

Once connections are set, we can run the sling conns list command to list our detected connections:

Test Connections

We can also test a connection by running the sling conns test command:

Discover Connections

We can easily discover streams available in a connection with the sling conns discover command:

Show column level information:

Credentials Location

Sling Env File (env.yaml)

The Sling Env file is the primary way sling reads connections. It needs to be saved in the path ~/.sling/env.yaml where the ~ denotes the path of the user Home folder, which can have different locations depending on the operating system (see here for Windows, here for Mac and here for Linux). Sling automatically creates the .sling folder in the user home directory, which is typically as shown below:

  • Linux: /home/<username>/.sling, or /root/.sling if user is root

  • Mac: /Users/<username>/.sling

  • Windows: C:\Users\<username>\.sling

Once in the user home directory, setting the Sling Env File (named env.yaml) is easy, and adheres to the structure below. Running sling the first time will auto-create it. You can alternatively provide the environment variable SLING_HOME_DIR.

To see what credential keys are necessary/accepted for each type of connector, click below:

  • File/Storage Connections (see here)

  • Database Connections (see here)

Environment Variables

Sling also reads environment variables. Simply export a connection URL (or YAML payload) to the current shell environment to use them.

To see examples of setting environment variables for each type of connector, click below:

  • File/Storage Connections (see here)

  • Database Connections (see here)

DBT Profiles (~/dbt/profiles.yml)

Sling also reads dbt profiles connections! If you're already set up with dbt cli locally, you don't need to create additional duplicate connections.

See here for more details.

Location String

The location string is a way to describe where sling should look for a file object or database object. It is used in a few places, such as the SLING_STATE env var, as well as Hooks such as delete, copy and inspect.

The proper input format is CONN_NAME/path/to/key for storage connections, or CONN_NAME/[database.]schema.table for database objects.

Local location examples:

  • local/relative/path

  • local/../parent/relative/path

  • local//absolute/linux/path

  • local/C:/absolute/windows/path

For cloud or remote storage connections (with defined AWS_S3, GCP, AZURE, SFTP connections):

  • aws_s3/path/to/folder

  • gcp/path/to/folder/file.parquet

  • azure/path/to/folder/file.log

  • sftp/relative/path/to/folder/file.log

  • sftp//absolute/path/to/folder/file.log

Database location examples (for hooks like inspect):

  • postgres/public.users - PostgreSQL table in public schema

  • mysql_db/analytics.events - MySQL table in analytics schema

  • snowflake/DATABASE.SCHEMA.TABLE - Snowflake table with explicit database

  • bigquery/project.dataset.table_name - BigQuery table

  • oracle_db/HR.EMPLOYEES - Oracle table in HR schema

  • mssql/dbo.customers - SQL Server table in dbo schema

Last updated

Was this helpful?