Skip to main content

Lightweight, pure-Python client for Snowflake's SQL API v2

Project description

snowflake-sql-api

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

Status: in active development, not yet released. The API may change before v0.1.0.

Why

The official snowflake-connector-python is ~75 MB installed (150 MB with pandas/pyarrow), has an 8-20 s cold start, and ships a compiled extension that slows container builds. 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
  • 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()"

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, and 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snowflake_sql_api-0.1.0.tar.gz (43.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snowflake_sql_api-0.1.0-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file snowflake_sql_api-0.1.0.tar.gz.

File metadata

  • Download URL: snowflake_sql_api-0.1.0.tar.gz
  • Upload date:
  • Size: 43.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for snowflake_sql_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b0a96619cfe7158c5ec7b6272804aaea161e213ca8db740a64583de9e663cf7
MD5 79347cd4e78a2faa4e8dbba63958ae9a
BLAKE2b-256 62b935f1f39e42e71e7e89ea76f4d233f0bb41c141192e7b3f5d1ba898878c9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for snowflake_sql_api-0.1.0.tar.gz:

Publisher: publish.yml on hampsterx/snowflake-sql-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file snowflake_sql_api-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for snowflake_sql_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9f2e266aa89da13a7d28b39d765f16c9637fa4f86fbd4be4acb4e0392d247b9
MD5 1e03163f304029ddaf4de143e2a29386
BLAKE2b-256 edfda4cf770a63b2cdf4d2d6f512021114226d28f5b5aa3c1359ba33ff333f90

See more details on using hashes here.

Provenance

The following attestation bundles were made for snowflake_sql_api-0.1.0-py3-none-any.whl:

Publisher: publish.yml on hampsterx/snowflake-sql-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page