About this project
fakesnow is a tool for running, mocking and testing fake Snowflake databases locally. It offers two approaches: in-process patching of the Snowflake Connector for Python, or a standalone HTTP server usable by connectors from any language.
In-process patching (Python): install with pip, then run a script via `fakesnow script.py` or a module such as pytest via `fakesnow -m pytest`. Alternatively use `fakesnow.patch()` as a context manager in code. Standard imports of `snowflake.connector.connect` and `snowflake.connector.pandas_tools.write_pandas` are patched automatically; modules using `from ... import` syntax must be named explicitly, e.g. `fakesnow.patch("mymodule.write_pandas")`. Patching applies only to the current process, so subprocesses and non-Python clients need the server. Databases are in-memory by default and can be persisted by passing a `db_path`.
Server mode: run `fakesnow -s` (or via uvx/docker, with the container listening on port 64616) to start an HTTP server. It can also be started inside a Python program with `fakesnow.server()`, which yields connection kwargs and stops the server on exit. Port and database persistence/isolation are configurable through session parameters such as `FAKESNOW_DB_PATH` (including the `:isolated:` value). Any username/password/account combination is accepted; the README documents connecting from the Snowflake CLI (config.toml with `protocol = http`), from Java via snowflake-jdbc (with notes about keeping `account` in the URL and JVM `--add-opens` for Arrow), and via Testcontainers.
pytest fixtures are provided through `pytest_plugins = "fakesnow.fixtures"`, including a session fixture and a `fakesnow_server` fixture that supplies connection kwargs.
Coverage: fully supported items include standard SQL operations and cursors, information schema queries, multiple databases, parameter binding, table comments, pandas integration including write_pandas, result batch retrieval via get_result_batches, and the HTTP server for non-Python connectors. Partially supported: date functions, regular expression functions, semi-structured data operations, tags, user management, stages and PUT, named file formats, and COPY INTO from S3 sources and stages. Not yet implemented: access control and stored procedures. The README notes caveats that row ordering is non-deterministic unless ORDER BY is fully specified, and that the supported SQL dialect is more liberal than real Snowflake, so some queries may work locally but not against a real instance. COPY INTO can use the standard AWS credential chain or a duckdb CREATE SECRET statement for alternative S3 credentials.
Comments
0 people shared their preference · Deer Point appears after 10 participants
Sign in to join the discussion.