# Snowflake Uploader (`svpetrenko/snowflake-uploader`) Actor

This actor uploads Apify datasets to Snowflake tables. You can use it with in a combination with webhooks to integrate your scrapers with Snowflake.

- **URL**: https://apify.com/svpetrenko/snowflake-uploader.md
- **Developed by:** [Sviatozar Petrenko](https://apify.com/svpetrenko) (community)
- **Categories:** Automation, Developer tools, Open source
- **Features:** Full permissions
- **Stats:** 13 total users, 1 monthly users, 0.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## What does Snowflake Uploader do?

Snowflake Uploader lets you upload any dataset to a DB provider [Snowflake](https://www.snowflake.com/en/). Use it for integration between Apify and Snowflake

## How to use Snowflake Uploader?

1. Go to [Snowflake Uploader](https://apify.com/svpetrenko/snowflake-uploader) on Apify
2. Click **Try for free** button
3. Enter scraper Input (see below): the dataset info, connection and transformation options.
4. Click the Start button
5. If the run is finished successfully, you should see data in your Snowflake table.

The power of this scraper will come if you set up webhooks on Apify scrapers that will call this uploader after completion.

## Input

The most important options for this scraper are connection options and datasetId. Other options allow you to manipualte your table schema and transform acquired json rows from the dataset. If you decide to set up a webhook for some scraper, it will by default post the default dataset id, so in this case you may omit it.

It might be convenient to set up a separate task with connection options. Then you'll be able to use a default webhook without modifying the payload at all.

# Actor input Schema

## `datasetId` (type: `string`):

Dataset of the ID to download the data from. If you set up a webhook, it will be posted in the default payload

## `tableName` (type: `string`):

Table name in the format DATABASE.SCHEMA.TABLENAME

## `username` (type: `string`):

Your acount's username

## `account` (type: `string`):

Account name. You can get it from the url, it's usually a set of letters and is not the same as your username.

## `password` (type: `string`):

Your account's password

## `database` (type: `string`):

Your database's name.

## `warehouse` (type: `string`):

Supply your custom warehouse name if you want. The deault works fine as well.

## `stage` (type: `string`):

Supply name of the stage where the file with data will be uploaded (with PUT). If you don't specify this, your table's default stage will be used.

## `flattenJson` (type: `boolean`):

If you select this option, instead of {a: {b: 1, c: \[1, 2]}} you'll get {a.b: 1, a.c.0: 1, a.c.1: 2}

## `transformJsonKeyFunction` (type: `string`):

Runs after flattening JSON. Enter body of a function that will transform JSON keys of dataset objecs. You have access to 'key' argument and must return a string. Example: 'return key.toLowerCase()'

## `transformJsonDataFunction` (type: `string`):

Runs after transforming keys. Enter the body of a function that will transform dataset objecs. You have access to 'value' argument that is a json object from dataset and must return a(n) (un)modified value. Example: `value.name += '/'; return value`

## `limit` (type: `integer`):

Limit the number of rows to be uploaded (e.g. for testing purposes on large datasets, because you have to wait for all your dataset to get transformed before pushing anything to the db). If you don't specify this, all rows will be uploaded.

## `overwrite` (type: `boolean`):

Whether to drop the table's data before pushing dataset data into it

## `synchronizeSchema` (type: `array`):

In case your destination table has a schema incompatible with the dataset, you can provide a list of column names and their types, then the table will be synchronized according to your definitions by dropping and recreating the table. Key is the column name, value is the column type (as in SQL query, like VARCHAR). This is optional if your table already has the desired schema.

## `dataLossConfirmation` (type: `boolean`):

If you choose to synchronize your schema or overwrite previous data, check this checkbox to confirm that you agree to lose your previous data

## `fileUploadRetries` (type: `integer`):

How many times to retry uploading the file to Snowflake. This setting is useful because this last operation sometimes fails for large datasets due to snoflake's driver

## Actor input object example

```json
{
  "warehouse": "COMPUTE_WH",
  "flattenJson": false,
  "overwrite": false,
  "dataLossConfirmation": false,
  "fileUploadRetries": 5
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("svpetrenko/snowflake-uploader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("svpetrenko/snowflake-uploader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call svpetrenko/snowflake-uploader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,svpetrenko/snowflake-uploader"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ktD6sgaWbZKHbPVmD/builds/YO4INN8Fq0pDkjRmQ/openapi.json
