{"id":9686,"library":"django-snowflake","title":"Django Snowflake Backend","description":"django-snowflake is a Django database backend that enables Django applications to connect to and use Snowflake data warehouses. It's currently at version 6.0 and is actively maintained, primarily releasing new versions to support the latest Django releases and address Snowflake-specific features or issues.","status":"active","version":"6.0","language":"en","source_language":"en","source_url":"https://github.com/Snowflake-Labs/django-snowflake","tags":["django","database","snowflake","backend"],"install":[{"cmd":"pip install django-snowflake","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This is a database backend for Django applications. Version 6.0 requires Django 5.x.","package":"Django","optional":false},{"reason":"Underlying Python connector for Snowflake.","package":"snowflake-connector-python","optional":false}],"imports":[{"note":"The correct engine path is simply 'django_snowflake', not a deeper internal module path.","wrong":"DATABASES = {'default': {'ENGINE': 'django_snowflake.base', ...}}","symbol":"ENGINE setting","correct":"DATABASES = {'default': {'ENGINE': 'django_snowflake', ...}}"}],"quickstart":{"code":"import os\n\nDATABASES = {\n    \"default\": {\n        \"ENGINE\": \"django_snowflake\",\n        \"NAME\": os.environ.get(\"SNOWFLAKE_DATABASE\", \"mydb\"),\n        \"USER\": os.environ.get(\"SNOWFLAKE_USER\", \"my_user\"),\n        \"OPTIONS\": {\n            \"ACCOUNT\": os.environ.get(\"SNOWFLAKE_ACCOUNT\", \"myaccount\"),\n            \"PASSWORD\": os.environ.get(\"SNOWFLAKE_PASSWORD\", \"\"),\n            \"WAREHOUSE\": os.environ.get(\"SNOWFLAKE_WAREHOUSE\", \"my_warehouse\"),\n            \"ROLE\": os.environ.get(\"SNOWFLAKE_ROLE\", \"my_role\"),\n            # Optional: Specify the schema if not using a DSN that includes it\n            \"SCHEMA\": os.environ.get(\"SNOWFLAKE_SCHEMA\", \"public\")\n            # For key-pair authentication, provide PRIVATE_KEY instead of PASSWORD:\n            # \"PRIVATE_KEY\": os.environ.get(\"SNOWFLAKE_PRIVATE_KEY\", \"\"),\n            # \"PRIVATE_KEY_PASSPHRASE\": os.environ.get(\"SNOWFLAKE_PRIVATE_KEY_PASSPHRASE\", \"\")\n        },\n    }\n}\n\n# Example of using a DSN (Data Source Name) instead of separate options:\n# DATABASES = {\n#     \"default\": {\n#         \"ENGINE\": \"django_snowflake\",\n#         \"NAME\": os.environ.get(\"SNOWFLAKE_DATABASE\", \"mydb\"),\n#         \"OPTIONS\": {\n#             \"DSN\": os.environ.get(\n#                 \"SNOWFLAKE_DSN\",\n#                 \"snowflake://{user}:{password}@{account}.snowflakecomputing.com/{database}/{schema}?warehouse={warehouse}&role={role}\"\n#             ).format(\n#                 user=os.environ.get(\"SNOWFLAKE_USER\", \"my_user\"),\n#                 password=os.environ.get(\"SNOWFLAKE_PASSWORD\", \"\"),\n#                 account=os.environ.get(\"SNOWFLAKE_ACCOUNT\", \"myaccount\"),\n#                 database=os.environ.get(\"SNOWFLAKE_DATABASE\", \"mydb\"),\n#                 schema=os.environ.get(\"SNOWFLAKE_SCHEMA\", \"public\"),\n#                 warehouse=os.environ.get(\"SNOWFLAKE_WAREHOUSE\", \"my_warehouse\"),\n#                 role=os.environ.get(\"SNOWFLAKE_ROLE\", \"my_role\")\n#             )\n#         },\n#     }\n# }","lang":"python","description":"Configure your `settings.py` `DATABASES` entry. It's recommended to use environment variables for sensitive credentials and connection details. The `NAME` parameter typically refers to the database in Snowflake. You can provide connection details via individual `OPTIONS` or a full `DSN` string."},"warnings":[{"fix":"Ensure your Django project is running Django 5.x. If not, upgrade Django or use an older compatible version of django-snowflake (e.g., v5.x for Django 4.x).","message":"django-snowflake v6.0 requires Django 5.x. Previous versions of django-snowflake supported older Django versions.","severity":"breaking","affected_versions":">=6.0"},{"fix":"You can safely remove `\"TYPE\": \"SNOWFLAKE\"` from your `DATABASES` configuration if you are on django-snowflake 5.0 or newer. It will not cause errors if left in.","message":"The `TYPE: 'SNOWFLAKE'` option is no longer required in `DATABASES` settings for django-snowflake versions >= 5.0. Including it is harmless but unnecessary.","severity":"gotcha","affected_versions":">=5.0"},{"fix":"Prefer either a complete DSN string OR individual `OPTIONS` parameters. Avoid using both for the same connection unless explicitly documented for specific overrides.","message":"When using a DSN (Data Source Name) in `OPTIONS`, ensure all required parameters (user, password, account, database, schema, warehouse, role) are correctly embedded or provided. Mixing DSN with individual options can lead to unexpected behavior.","severity":"gotcha","affected_versions":"all"},{"fix":"Set `\"SCHEMA\": \"your_schema_name\"` in the `OPTIONS` dictionary of your `DATABASES` configuration to ensure Django queries target the correct schema.","message":"Snowflake's default session schema might not be 'public'. If your Django models expect a specific schema, you must define it explicitly in the `SCHEMA` option or within the DSN.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Run `pip install django-snowflake` and verify that `DATABASES['default']['ENGINE']` is set to `'django_snowflake'`.","cause":"The `django-snowflake` package is not installed or the `ENGINE` string in `settings.py` is misspelled.","error":"django.core.exceptions.ImproperlyConfigured: 'django_snowflake' isn't an available database backend. Try using 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'."},{"fix":"Install the underlying Snowflake connector: `pip install snowflake-connector-python`.","cause":"The `snowflake-connector-python` dependency, required by `django-snowflake`, is not installed in your environment.","error":"ModuleNotFoundError: No module named 'snowflake.connector'"},{"fix":"Double-check your `USER`, `PASSWORD`, `ACCOUNT`, `WAREHOUSE`, and `ROLE` settings in `DATABASES['default']['OPTIONS']`. Ensure your network allows outbound connections to Snowflake endpoints.","cause":"Incorrect credentials (user, password, account, role, warehouse) or network issues preventing connection to Snowflake.","error":"django.db.utils.OperationalError: Failed to connect to DB: <your-account>.snowflakecomputing.com:443. ... Invalid username or password."},{"fix":"Add `\"NAME\": \"your_snowflake_database\"` to your `DATABASES['default']` configuration. Even when using a DSN, a top-level `NAME` might be expected or can be deduced from the DSN itself.","cause":"The `NAME` parameter is missing from the `DATABASES` configuration, which is required by `django-snowflake` to specify the Snowflake database.","error":"django.core.exceptions.ImproperlyConfigured: The DATABASE 'default' engine was missing the following key(s): NAME"}]}