Skip to main content

Python model and query builder for Snowflake.

Project description

Snowman

pypi package python-test rust-test

logo

Python model and query builder for Snowflake.

Install

pip install snowman-py

CLI Tool

Create Snowman Config

snowman config create

Generate Python Model From Snowflake Information Schema

snowman model generate

Query Builder

Insert Query

import textwrap

from snowman.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 snowman.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 snowman.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 snowman.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

snowman_py-0.0.7.tar.gz (32.0 kB view hashes)

Uploaded Source

Built Distributions

snowman_py-0.0.7-py3-none-win_amd64.whl (2.8 MB view hashes)

Uploaded Python 3 Windows x86-64

snowman_py-0.0.7-py3-none-win32.whl (2.4 MB view hashes)

Uploaded Python 3 Windows x86

snowman_py-0.0.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.6 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

snowman_py-0.0.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (6.5 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

snowman_py-0.0.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (6.7 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ i686

snowman_py-0.0.7-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.8 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

snowman_py-0.0.7-py3-none-macosx_11_0_arm64.whl (3.1 MB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

snowman_py-0.0.7-py3-none-macosx_10_12_x86_64.whl (3.2 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