Skip to main content

snowflake-sql-api

CI PyPI Python versions License: MIT Typed

A lightweight, pure-Python client for Snowflake's SQL API v2 (the POST /api/v2/statements REST endpoint).

Status: pre-1.0. The API may still change between minor versions.

Why

The official snowflake-connector-python is ~75 MB installed (150 MB with pandas/pyarrow) and ships a compiled extension that slows container builds and inflates cold starts (its import alone is ~1.5 s versus ~0.3 s for this client). For serverless and AWS Lambda workloads that only need to run SQL, that is a lot of weight.

snowflake-sql-api talks to Snowflake's SQL API over plain HTTP (httpx), so it stays small and cold-starts quickly. Core dependencies: httpx, PyJWT, cryptography.

Features

  • Synchronous and asynchronous clients with the same surface
  • Keypair (JWT) authentication, including encrypted private keys
  • Result type coercion (NUMBER/Decimal, dates/timestamps, VARIANT, and more)
  • Multi-partition result handling for large result sets
  • Lazy row streams and bounded row batches, with CSV and JSONL exports
  • Query helpers, DML, batch insert, async statement submission
  • A small CLI for ad-hoc queries
  • Optional pandas ([pandas]) and typed-row ([pydantic]) helpers, kept out of the default install

Install

pip install snowflake-sql-api
# optional extras
pip install "snowflake-sql-api[pandas]"
pip install "snowflake-sql-api[pydantic]"

Quick start

from snowflake_sql_api import SnowflakeClient

client = SnowflakeClient(
    account="myorg-myaccount",
    user="MY_USER",
    private_key_path="/path/to/rsa_key.p8",
)

rows = client.query("SELECT id, name FROM users WHERE active = ?", [True])
for row in rows:
    print(row["ID"], row["NAME"])

Async:

from snowflake_sql_api import AsyncSnowflakeClient

async with AsyncSnowflakeClient.from_env() as client:
    rows = await client.query("SELECT current_timestamp()")

CLI:

snowflake-sql-api query "SELECT current_version()"

Stream large results or export them without collecting every row:

with SnowflakeClient.from_env() as client:
    for batch in client.query_batches("SELECT id, amount FROM sales", batch_size=500):
        process(batch)

    with open("sales.csv", "w", encoding="utf-8", newline="") as output:
        count = client.export_csv("SELECT id, amount FROM sales", output)

Streaming fetches completed results one server partition at a time. Memory scales with the largest decoded partition plus the application batch. See streaming results and exports for row streams, async usage, serialization, and partial-output behavior.

Insert a record stream in bounded requests:

with SnowflakeClient.from_env() as client:
    progress = client.insert_batches(
        "events", ["id", "label"], ((i, f"event {i}") for i in range(2500)),
        max_rows=1000, max_bytes=1_000_000,
    )
    print(progress.input_rows, progress.rows_affected)

insert_many() sends one statement; insert_batches() sends sequential statements and can partially complete. Its byte budget covers the exact JSON body. On failure, BatchWriteError reports confirmed progress, consumed input and the failed request's identity. Reconstruct replayable input and reconcile unknown outcomes before retrying; do not resume with the same advanced iterator. The async equivalent is awaited and accepts the same synchronous iterable, whose production can block the event loop. See batch writes for limits and recovery semantics.

Prior art and alternatives

snowflake-sql-api is not the first REST-based Snowflake client. If it does not fit your needs, one of these might:

Project Language Notes
snowflake-connector-python Python Official driver. Full-featured (DB-API, pandas/Arrow, every auth mode) but large and slow to cold-start. Use it when you need the full driver.
snowflake-rest Python The closest prior art and a direct inspiration for this project's API. Pure-Python over requests, sync-only, currently low-activity.
snowflake-sql-api-async Python Async-focused, but depends on snowflake-connector-python.
snowflake-sql-api-client Python Low-level generated wrapper; unmaintained since 2022.
rb_snowflake_client Ruby Mature pure-Ruby SQL API client (streaming, connection pooling).
rsql Rust Multi-database SQL CLI with a Snowflake SQL API driver.

How snowflake-sql-api differs: pure Python over httpx, with no dependency on the official connector (small install, fast cold start), paired sync and async clients, keypair auth, type coercion, partition handling, and a CLI as tested first-class behavior.

Note: the similarly named snowflake-sql-api-async and snowflake-sql-api-client are separate, unaffiliated projects.

Acknowledgements

The API design is inspired by pps-19012/snowflake-rest by Pushpendra Singh. This is a clean-room implementation (no code copied); credit for the original design and API shape goes to its author.

License

MIT

Metadata

Release files for snowflake-sql-api 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowflake-sql-api 0.1.4
File Size Uploaded Provenance
snowflake_sql_api-0.1.4.tar.gz 68.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for snowflake-sql-api 0.1.4
File Interpreter ABI Platform
snowflake_sql_api-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 115.8 kB

Release files / snowflake_sql_api-0.1.4.tar.gz

Download URL snowflake_sql_api-0.1.4.tar.gz
Size 68.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a8ee17eb23a7db02c3146bd65ff16cfd74d1560b98ec8baa90de7057edd2f6df
BLAKE2b-256 checksum
How to use checksums
40de355c7d795c41663463dc343adfc1c2ae6c0783f39c26900dcb38d763414b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / snowflake_sql_api-0.1.4-py3-none-any.whl

Download URL snowflake_sql_api-0.1.4-py3-none-any.whl
Size 47.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dadb7670bd1dd4f6805395bccc6800414e084df9be0f1934cb4423db829a8525
BLAKE2b-256 checksum
How to use checksums
765d057f507024be8276e0d544c7b6b090c48e454c0ed8601ed40fd17aebce84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for snowflake-sql-api 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for snowflake_sql_api-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page