Snowflake File Ingest SDK
raw JSON → 1.0.12 verified Fri May 01 auth: no python
Official Snowflake SDK for bulk file ingestion via Snowpipe. Version 1.0.12 supports streaming ingest and historical file loading. Released monthly.
pip install snowflake-ingest Common errors
error snowflake.ingest.exceptions.SnowflakeIngestError: Error 301: Authentication token is invalid ↓
cause Private key format is incorrect or the key is not in PKCS8 format.
fix
Convert private key to PKCS8 format: openssl pkcs8 -topk8 -inform PEM -outform PEM -in rsa_key.pem -out rsa_key.p8 -nocrypt
error ModuleNotFoundError: No module named 'snowflake.ingest' ↓
cause The library is installed as 'snowflake-ingest' but import path is wrong.
fix
Install with: pip install snowflake-ingest, then import as: from snowflake.ingest import ...
error AttributeError: module 'snowflake.ingest' has no attribute 'SnowflakeIngestManager' ↓
cause Older version of the library (pre-1.0.0) used different class names.
fix
Upgrade to >=1.0.0: pip install --upgrade snowflake-ingest
Warnings
breaking In version 1.0.0, the authentication method changed from using 'private_key_file' to requiring a raw bytes private key. ↓
fix Replace 'private_key_file' parameter with 'private_key' and read the file as bytes.
deprecated The method 'ingest_files' (plural) is deprecated in favor of 'ingest_file' (singular) with a batch parameter. ↓
fix Use manager.ingest_file(request) for single file, or call it in a loop for multiple files.
gotcha SnowflakeIngestManager does not support account identifiers with hyphens. Use the full account name without dashes. ↓
fix Replace dashes with underscores or use the locator form (e.g., 'myorg-myaccount' -> 'myorg_myaccount').
gotcha File ingestion requests for historical files (files already in stage) must use the 'historical: true' flag, otherwise they are ignored. ↓
fix Set historical=True in FileIngestionRequest if the file already exists in the stage.
Imports
- SnowflakeIngestManager
from snowflake.ingest import SnowflakeIngestManager - IngestError
from snowflake.ingest import IngestError - FileIngestionRequest
from snowflake.ingest import FileIngestionRequest
Quickstart
import os
from snowflake.ingest import SnowflakeIngestManager, FileIngestionRequest
manager = SnowflakeIngestManager(
account=os.environ.get('SNOWFLAKE_ACCOUNT', ''),
user=os.environ.get('SNOWFLAKE_USER', ''),
private_key=open('/path/to/rsa_key.p8', 'rb').read(),
database='MYDB',
schema='PUBLIC'
)
request = FileIngestionRequest(
file='data.csv',
stage='MYSTAGE',
prefix='data/',
pipe='MYPIPE'
)
manager.ingest_file(request)
print('File ingested successfully')