{"id":8649,"library":"sling","title":"Sling","description":"Sling is a modern ELT (Extract, Load, Transform) data movement tool that allows users to rapidly move data between various databases, data warehouses, and cloud services using a simple Python API or CLI. It supports a wide range of connectors and focuses on ease of use and high performance. The current version is 1.5.15, with a rapid release cadence (multiple updates per month).","status":"active","version":"1.5.15","language":"en","source_language":"en","source_url":"https://github.com/slingdata-io/sling-python","tags":["ETL","ELT","data-integration","data-movement","data-pipeline","database","cloud-data-warehouse","connectors"],"install":[{"cmd":"pip install sling","lang":"bash","label":"Install core library"},{"cmd":"pip install sling[snowflake,postgres]","lang":"bash","label":"Install with optional database connectors"}],"dependencies":[{"reason":"Used for configuration parsing.","package":"pyyaml","optional":false},{"reason":"Used for HTTP API interactions, critical for many connectors.","package":"requests","optional":false}],"imports":[{"note":"All core components are exposed directly from the top-level 'sling' package.","wrong":"from sling.connections import Connection","symbol":"Connection","correct":"from sling import Connection"},{"note":"Source definition for data ingestion.","symbol":"Source","correct":"from sling import Source"},{"note":"Target definition for data destination.","symbol":"Target","correct":"from sling import Target"},{"note":"The 'run' function for executing a data sling job is exposed directly from 'sling'.","wrong":"from sling.jobs import run","symbol":"run","correct":"from sling import run"}],"quickstart":{"code":"import os\nfrom sling import Connection, Source, Target, run\n\n# Configure connections using environment variables for sensitive data\n# For a real run, ensure these environment variables are set:\n# SLING_PG_HOST, SLING_PG_USER, SLING_PG_PASS, SLING_PG_DB\n# SLING_SNF_ACCOUNT, SLING_SNF_USER, SLING_SNF_PASS, SLING_SNF_DB, SLING_SNF_WAREHOUSE\n\npostgres_conn = Connection(\n    name='my_postgres',\n    type='postgres',\n    host=os.environ.get('SLING_PG_HOST', 'localhost'),\n    port=5432,\n    user=os.environ.get('SLING_PG_USER', 'user'),\n    password=os.environ.get('SLING_PG_PASS', 'password'),\n    database=os.environ.get('SLING_PG_DB', 'source_db')\n)\n\nsnowflake_conn = Connection(\n    name='my_snowflake',\n    type='snowflake',\n    account=os.environ.get('SLING_SNF_ACCOUNT', 'your_account'),\n    user=os.environ.get('SLING_SNF_USER', 'user'),\n    password=os.environ.get('SLING_SNF_PASS', 'password'),\n    database=os.environ.get('SLING_SNF_DB', 'target_db'),\n    warehouse=os.environ.get('SLING_SNF_WAREHOUSE', 'COMPUTE_WH')\n)\n\n# Define source and target for a simple table copy\nsource_table = Source(\n    connection=postgres_conn,\n    object='public.my_source_table'\n)\n\ntarget_table = Target(\n    connection=snowflake_conn,\n    object='public.my_target_table',\n    mode='full_refresh' # or 'append', 'incremental'\n)\n\n# Run the data sling job\ntry:\n    result = run(source_table, target_table)\n    print(f\"Sling job completed. Rows replicated: {result.rows_replicated}\")\nexcept Exception as e:\n    print(f\"Sling job failed: {e}\")\n\n# Example of retrieving connection by name if already added to a global registry (e.g., via CLI or config file)\n# connection = Connection.get_connection('my_postgres')\n","lang":"python","description":"This quickstart demonstrates how to define a PostgreSQL source and a Snowflake target, then execute a data movement job. It uses environment variables for sensitive connection details, which is a recommended practice. Ensure you have the necessary `sling` extras installed (e.g., `sling[postgres,snowflake]`) and your environment variables configured for a successful run."},"warnings":[{"fix":"Refer to the official Sling documentation for each specific connector's required `Connection` parameters and their expected types/formats. Common errors include missing `host`, `port`, `account`, or `schema` fields.","message":"Connection parameters vary significantly by connection type. Ensure you consult the documentation for the specific source/target connector (e.g., PostgreSQL, Snowflake, S3) to provide all required and optional parameters.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Decide whether to manage Sling connections and jobs programmatically in Python or via the CLI's configuration files. If using the Python API, instantiate `Connection` objects directly. If using the CLI, define connections and jobs in `~/.sling/connections.yaml` or similar configuration files.","message":"Sling provides both a Python library for programmatic use and a CLI tool. While `sling run` works for both, the CLI allows managing connections and sources via configuration files, which is separate from Python API's direct object instantiation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For complex cases, use the `stream_config` parameter on `Source` or `Target` to specify explicit data type mappings (`schema_mapping`) or transformation logic. Test with a subset of data to validate schema and data integrity before full runs.","message":"Schema inference might not always perfectly match complex data types or custom schemas. Sometimes, manual schema mapping or data type casting is required.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify that the `user` and `password` parameters in your `Connection` object are correct and match the database server's requirements. Ensure environment variables (if used) are properly set and accessible.","cause":"Incorrect or missing authentication credentials (user, password) for the database connection.","error":"sling.exceptions.SlingConnectionException: Failed to connect to database: fe_sendauth: no password supplied"},{"fix":"Change your import statement from `from sling.connections import Connection` (or similar for other components) to `from sling import Connection` (or `from sling import Source, Target, run`).","cause":"Attempting to import submodules directly instead of the top-level package. All core classes and functions are exposed directly under the `sling` package.","error":"ModuleNotFoundError: No module named 'sling.connections'"},{"fix":"Use `os.environ.get('KEY', '')` or `os.environ.get('KEY', None)` to safely retrieve environment variables and provide a default value or handle the `None` case, preventing the `KeyError`.","cause":"Attempting to access an environment variable directly via `os.environ['KEY']` which is not set, instead of using `os.environ.get('KEY', default_value)`.","error":"KeyError: 'SomeEnvVar'"}]}