Metadata-Version: 2.4
Name: snowflake-sql-api
Version: 0.1.1
Summary: Lightweight, pure-Python client for Snowflake's SQL API v2
Project-URL: Homepage, https://github.com/hampsterx/snowflake-sql-api
Project-URL: Repository, https://github.com/hampsterx/snowflake-sql-api
Project-URL: Issues, https://github.com/hampsterx/snowflake-sql-api/issues
Author: hampsterx
License: MIT License
        
        Copyright (c) 2026 hampsterx
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: api,httpx,lambda,rest,serverless,snowflake,sql
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Database
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: cryptography>=3.4
Requires-Dist: httpx>=0.24
Requires-Dist: pyjwt>=2.4
Provides-Extra: dev
Requires-Dist: black<25.12,>=24.0; extra == 'dev'
Requires-Dist: build>=1.0; extra == 'dev'
Requires-Dist: coverage[toml]>=7.0; extra == 'dev'
Requires-Dist: mypy>=1.8; extra == 'dev'
Requires-Dist: pre-commit>=3.5; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: respx>=0.20; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Provides-Extra: pandas
Requires-Dist: pandas>=1.3; extra == 'pandas'
Provides-Extra: pydantic
Requires-Dist: pydantic>=2.0; extra == 'pydantic'
Description-Content-Type: text/markdown

# snowflake-sql-api

A lightweight, pure-Python client for [Snowflake's SQL API v2](https://docs.snowflake.com/en/developer-guide/sql-api/index)
(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`](https://pypi.org/project/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

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

## Quick start

```python
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:

```python
from snowflake_sql_api import AsyncSnowflakeClient

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

CLI:

```bash
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`](https://github.com/snowflakedb/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`](https://github.com/pps-19012/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`](https://github.com/neonblue-ai/snowflake-sql-api-async) | Python | Async-focused, but depends on `snowflake-connector-python`. |
| [`snowflake-sql-api-client`](https://pypi.org/project/snowflake-sql-api-client/) | Python | Low-level generated wrapper; unmaintained since 2022. |
| [`rb_snowflake_client`](https://github.com/rinsed-org/rb-snowflake-client) | Ruby | Mature pure-Ruby SQL API client (streaming, connection pooling). |
| [`rsql`](https://github.com/theseus-rs/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`](https://github.com/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
