# Installation

{% embed url="<https://f.slingdata.io/videos/sling.cli.demo.2023.10.720.mp4>" %}
Sling CLI Demo
{% endembed %}

## Getting Started

`sling` CLI is a free tool that allows data extraction and loading from / into many popular databases / storage platforms. Follow the instructions below to install it on your respective operating system.

### Installation

All commands below will install the latest version of sling. If you'd like to determine which version is latest/current, you can check out the [releases page](https://github.com/slingdata-io/sling-cli/releases) on github.

#### Brew on Mac

Follow these [directions](https://brew.sh/) to install HomeBrew for mac if not already installed.

```shell
# Install with brew first
brew install slingdata-io/sling/sling

# Once, installed, `sling` should be available
sling -h
```

#### Scoop on Windows

```powershell
scoop bucket add sling https://github.com/slingdata-io/scoop-sling.git
scoop install sling

# You're good to go!
sling -h
```

#### Linux

```shell
# download latest binary
curl -LO 'https://github.com/slingdata-io/sling-cli/releases/latest/download/sling_linux_amd64.tar.gz' \
  && tar xf sling_linux_amd64.tar.gz \
  && rm -f sling_linux_amd64.tar.gz \
  && chmod +x sling

# You're good to go!
./sling -h
```

#### Docker

```shell
docker pull slingdata/sling

docker run --rm -i slingdata/sling --help
```

#### Other Binary Downloads

See [Releases](https://github.com/slingdata-io/sling-cli/releases) on Github.

### Setting up your Connections

Sling looks for credentials in several places:

* Environment Variables
* Sling Env File (located at `~/.sling/env.yaml`)
* DBT Profiles Files (located at `~/.dbt/profiles.yml`)

Please see [environment](/sling-cli/environment.md) for more details.

## Using Sling

`sling` CLI is designed to be easy to use. Say we want to load a CSV file into a PostgreSQL database. We could run the following command:

{% tabs %}
{% tab title="Linux" %}
{% code overflow="wrap" %}

```bash
export MY_PG='postgresql://user:mypassw@pg.host:5432/db1'

sling run --src-stream file:///path/to/myfile.csv --tgt-conn MY_PG --tgt-object public.my_new_data

# OR pipe it in
cat /path/to/myfile.csv | sling run --tgt-conn MY_PG --tgt-object public.my_new_data
```

{% endcode %}
{% endtab %}

{% tab title="Mac" %}
{% code overflow="wrap" %}

```bash
export MY_PG='postgresql://user:mypassw@pg.host:5432/db1'

sling run --src-stream file:///path/to/myfile.csv --tgt-conn MY_PG --tgt-object public.my_new_data

# OR pipe it in
cat /path/to/myfile.csv | sling run --tgt-conn MY_PG --tgt-object public.my_new_data
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" %}

```powershell
# using windows Powershell
$env:MY_PG = 'postgresql://user:mypassw@pg.host:5432/db1'
sling run --src-stream file://C:/path/to/myfile.csv --tgt-conn MY_PG --tgt-object public.my_new_data

# OR pipe it in
cat C:\path\to\myfile.csv | sling run --tgt-conn MY_PG --tgt-object public.my_new_data
```

{% endcode %}
{% endtab %}

{% tab title="Docker" %}
{% code overflow="wrap" %}

```bash
export MY_PG='postgresql://user:mypassw@pg.host:5432/db1'

docker run --rm -i -e MY_PG -v /path/to/myfile.csv slingdata/sling run --src-stream file:///path/to/myfile.csv --tgt-conn MY_PG --tgt-object public.my_new_data
```

{% endcode %}
{% endtab %}
{% endtabs %}

### With Python

If you have Python `pip` installed, you can simply run:

```bash
pip install sling
```

You call also check out the [Python wrapper](https://github.com/slingdata-io/sling-python) library on github.

```python
from sling import Replication, ReplicationStream

replication = Replication(
  source='MY_PG',
  target='MY_AWS_S3',
  steams={
    "my_table": ReplicationStream(
      sql="select * from my_table",
      object='my_folder/new_file.csv',
    ),
  }
)

replication.run()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/sling-cli/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
