Skip to main content

Fake Snowflake Connector for Python. Run Snowflake DB locally.

Project description

fakesnow ❄️

ci release PyPI

Fake Snowflake Connector for Python. Run and mock Snowflake DB locally.

Install

pip install fakesnow

Usage

import fakesnow
import snowflake.connector

with fakesnow.patch():
    conn = snowflake.connector.connect()

    print(conn.cursor().execute("SELECT 'Hello fake world!'").fetchone())

The following imports are automatically patched:

  • import snowflake.connector.connect
  • import snowflake.connector.pandas_tools.write_pandas

To patch modules that use the from ... import syntax, manually specify them, eg: if mymodule.py has the import:

from snowflake.connector.pandas_tools import write_pandas

Then patch it using:

with fakesnow.patch("mymodule.write_pandas"):
    ...

pytest fixtures are provided for testing. Example conftest.py:

from typing import Iterator

import fakesnow.fixtures
import pytest

pytest_plugins = fakesnow.fixtures.__name__

@pytest.fixture(scope="session", autouse=True)
def setup(_fakesnow_session: None) -> Iterator[None]:
    # the standard imports are now patched
    ...
    yield

Or with from ... import patch targets:

from typing import Iterator

import fakesnow
import pytest

@pytest.fixture(scope="session", autouse=True)
def _fakesnow_session() -> Iterator[None]:
    with fakesnow.patch("mymodule.write_pandas"):
        yield

Implementation coverage

Partial support

  • date functions
  • regex functions
  • semi-structured data
  • tags

For more detail see tests/test_fakes.py

Caveats

  • VARCHAR field sizes are not enforced unlike Snowflake which will error with "User character length limit (xxx) exceeded by string" when you try to insert a string longer than the column limit.

Contributing

See CONTRIBUTING.md to get started and develop in this repo.

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

fakesnow-0.7.1.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

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

fakesnow-0.7.1-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file fakesnow-0.7.1.tar.gz.

File metadata

  • Download URL: fakesnow-0.7.1.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for fakesnow-0.7.1.tar.gz
Algorithm Hash digest
SHA256 df2f98e45db545302ab5f9d6c4e215210b1bcbcfff006739899fe1ca2ea53d98
MD5 2c42d4b453823393a50845c651eeb71c
BLAKE2b-256 803cb67587f2d72475ffb83860d650bfc6918a9ea8d5a175b322e9b3c039d3c0

See more details on using hashes here.

File details

Details for the file fakesnow-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: fakesnow-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for fakesnow-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 530f061315ac6b377fe4902a8708cbebaf9c3aa524ec8d6e7fc2b69d63fcbe2a
MD5 9b16f206af70e064f55a210845e9fd3a
BLAKE2b-256 6f8ef143172ec8f9d2a62b32cf833f7fbe523c587b959129eb9a89851c57dcc2

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