Skip to main content

Async Snowflake connector for Python with JWT authentication

Project description

Async Snowflake Connector for Python

An async Python connector for Snowflake using JWT authentication.

Installation

pip install -r requirements.txt

Configuration

Credentials File

Create a credentials.toml file (do not commit to version control):

[default]
account = "YOUR_ACCOUNT"
user = "YOUR_USER"
private_key_path = "/path/to/private_key.pem"
region = "us-east-1"

# Multiple profiles supported
[production]
account = "PROD_ACCOUNT"
user = "admin"
private_key_path = "/path/to/prod_key.pem"

Environment Variables

Alternatively, use environment variables:

export SNOWFLAKE_ACCOUNT="your_account"
export SNOWFLAKE_USER="your_user"
export SNOWFLAKE_PRIVATE_KEY_PATH="/path/to/key.pem"
export SNOWFLAKE_REGION="us-east-1"

Usage

from endpoints import SnowflakeClient
from authentication import SnowflakeJWTAuthClient
from authentication.credentials import CredentialsManager

# Option 1: Using credentials manager
credentials = CredentialsManager(profile="default").credentials

auth = SnowflakeJWTAuthClient(
    account=credentials.account,
    user=credentials.user,
    private_key_path=credentials.private_key_path,
)

client = await SnowflakeClient.create(
    base_url=credentials.base_url,
    auth_client=auth,
)

# Execute query
result = await client.query.execute("SELECT * FROM table")
print(result.data)

await client.close()

# Option 2: Using context manager
async with SnowflakeClient.create(base_url, auth) as client:
    result = await client.query.execute("SELECT 1")

Fluent Interface

# Account operations
await client.account.get_current_account()

# Database operations
await client.database.list()
await client.database.create("new_db")
await client.database.describe("my_db")

# Warehouse operations
await client.warehouse.list()
await client.warehouse.resume("warehouse_name")

# Query execution
result = await client.query.execute("SELECT * FROM table")

Testing

# Run all tests
uv run pytest tests/ -v

# Run only unit tests
uv run pytest tests/unit/ -v

# Run only integration tests
uv run pytest tests/integration/ -v

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

async_snowflake-0.1.0.tar.gz (67.9 kB view details)

Uploaded Source

Built Distribution

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

async_snowflake-0.1.0-py3-none-any.whl (43.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: async_snowflake-0.1.0.tar.gz
  • Upload date:
  • Size: 67.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for async_snowflake-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5621a535f81e08d7f8b3918d320f733243a3b2d1384221a03ea743996def5dd3
MD5 d0a46f1cc98269d8c66550acf631ab15
BLAKE2b-256 b78473f5a760fd96fba771c8a6d77c3498a5f5f8c0fa68d4afb6df9e0485fe98

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for async_snowflake-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 06e02d0db80e8fa4be6750fd4d0dbf7a48528e4de22537198267cd64cf821f6a
MD5 1968da90bf274f6a7588e65038ff7bb1
BLAKE2b-256 3ce41824dff41236473c524a4863729035cf83175dbc6a4e2bf6aee6d01105db

See more details on using hashes here.

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