Environment
Sling looks for connection credentials in several places:
Sling Env File (located at
~/.sling/env.yaml)DBT Profiles Files (located at
~/.dbt/profiles.yml)
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:
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)
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/.slingif user isrootMac:
/Users/<username>/.slingWindows:
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:
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:
DBT Profiles (~/dbt/profiles.yml)
~/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/pathlocal/../parent/relative/pathlocal//absolute/linux/pathlocal/C:/absolute/windows/path
For cloud or remote storage connections (with defined AWS_S3, GCP, AZURE, SFTP connections):
aws_s3/path/to/foldergcp/path/to/folder/file.parquetazure/path/to/folder/file.logsftp/relative/path/to/folder/file.logsftp//absolute/path/to/folder/file.log
Database location examples (for hooks like inspect):
postgres/public.users- PostgreSQL table in public schemamysql_db/analytics.events- MySQL table in analytics schemasnowflake/DATABASE.SCHEMA.TABLE- Snowflake table with explicit databasebigquery/project.dataset.table_name- BigQuery tableoracle_db/HR.EMPLOYEES- Oracle table in HR schemamssql/dbo.customers- SQL Server table in dbo schema
For file storage connections (local, ftp and sftp), you can specify a relative or absolute path. For FTP connections, it will be relative to the default folder of the username connecting.
Relative Path: You use the typical single slash (/) after the connection name:
local/relative/pathsftp/relative/pathftp/relative/path
Absolute Path: You need to add 2 slashes (//) after the connection name:
local//absolute/pathlocal/C:/absolute/pathsftp//absolute/pathftp//absolute/path
For database connections, use the standard database object naming convention: connection_name/[database.]schema.table_name
Last updated
Was this helpful?