Skip to main content

snowflake query builder for python.

Project description

snowq

Easily build and execute Snowflake queries in Python.

CLI Tool

Create snowq Config

snowq config create

Generate Python Model from Snowflake information schema

snowq model import

Query Builder

Insert Query

import textwrap

from snowq.query import insert

from your.database.schema import User

query, params = (
    insert.into(
        User,
    ).values(
        {
            "id": 1,
            "name": "John Doe",
        }
    )
).build()

expected = textwrap.dedent(
    """
    INSERT INTO
        database.schema.users
    VALUES (
        %(id)s,
        %(name)s
    )
    """
).strip()

assert query == expected

Update Query

import textwrap

from snowq.query import update

from your.database.schema import User

query, params = (
    update(
        User,
    )
    .set(
        {"name": "Jane Doe"},
    )
    .where(
        "id = 1",
    )
).build()

expected = textwrap.dedent(
    """
    UPDATE
        database.schema.users
    SET
        name = %(name)s
    WHERE
        id = 1
    """
).strip()

assert query == expected

Delete Query

import textwrap

from snowq.query import delete

from your.database.schema import User

query, params = (
    delete.from_(
        User,
    ).where(
        "id = 1",
    )
).build()

expected = textwrap.dedent(
    """
    DELETE FROM
        database.schema.users
    WHERE
        id = 1
    """
).strip()

assert query == expected

Truncate Query

from snowq.query import truncate

from your.database.schema import User

query, params = truncate.table(User).build()

expected = "TRUNCATE TABLE database.schema.users"

assert query == expected

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

snowq-0.0.2.tar.gz (29.7 kB view hashes)

Uploaded Source

Built Distributions

snowq-0.0.2-py3-none-win_amd64.whl (2.7 MB view hashes)

Uploaded Python 3 Windows x86-64

snowq-0.0.2-py3-none-win32.whl (2.4 MB view hashes)

Uploaded Python 3 Windows x86

snowq-0.0.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.5 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

snowq-0.0.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (6.4 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

snowq-0.0.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (6.6 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ i686

snowq-0.0.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.7 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

snowq-0.0.2-py3-none-macosx_11_0_arm64.whl (3.0 MB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

snowq-0.0.2-py3-none-macosx_10_12_x86_64.whl (3.1 MB view hashes)

Uploaded Python 3 macOS 10.12+ x86-64

Supported by

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