Fake Snowflake Connector for Python. Run Snowflake DB locally.
Project description
fakesnow ❄️
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
- multiple databases
- cursors
- get_result_batches()
- write_pandas(..)
- table comments
- qmark binding
- access control
- standalone/out of process api/support for faking non-python connectors
- stored procedures
Partial support
- date functions
- tags
- semi-structured data
For more detail see tests/test_fakes.py
Contributing
See CONTRIBUTING.md to get started and develop in this repo.
Project details
Release history Release notifications | RSS feed
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.2.0.tar.gz
(21.5 kB
view hashes)
Built Distribution
fakesnow-0.2.0-py3-none-any.whl
(16.3 kB
view hashes)