{"id":31482313,"url":"https://github.com/snowflake-labs/django-snowflake","last_synced_at":"2025-10-02T07:47:36.446Z","repository":{"id":43395381,"uuid":"415938562","full_name":"Snowflake-Labs/django-snowflake","owner":"Snowflake-Labs","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-12T13:33:09.000Z","size":160,"stargazers_count":79,"open_issues_count":13,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-09-12T16:00:04.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Snowflake-Labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-10-11T13:28:32.000Z","updated_at":"2025-07-30T22:20:22.000Z","dependencies_parsed_at":"2023-12-08T04:23:59.916Z","dependency_job_id":"879108a1-7fc0-4778-9160-268787da6683","html_url":"https://github.com/Snowflake-Labs/django-snowflake","commit_stats":null,"previous_names":["cedar-team/django-snowflake"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/Snowflake-Labs/django-snowflake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snowflake-Labs%2Fdjango-snowflake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snowflake-Labs%2Fdjango-snowflake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snowflake-Labs%2Fdjango-snowflake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snowflake-Labs%2Fdjango-snowflake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Snowflake-Labs","download_url":"https://codeload.github.com/Snowflake-Labs/django-snowflake/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snowflake-Labs%2Fdjango-snowflake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277974415,"owners_count":25908396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-02T02:00:08.890Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-02T07:47:33.503Z","updated_at":"2025-10-02T07:47:36.440Z","avatar_url":"https://github.com/Snowflake-Labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Snowflake backend for Django\n\n## Install and usage\n\nUse the version of django-snowflake that corresponds to your version of\nDjango. For example, to get the latest compatible release for Django 5.2.x:\n\n`pip install django-snowflake==5.2.*`\n\nThe minor release number of Django doesn't correspond to the minor release\nnumber of django-snowflake. Use the latest minor release of each.\n\nConfigure the Django `DATABASES` setting similar to this:\n\n```python\nDATABASES = {\n    'default': {\n        'ENGINE': 'django_snowflake',\n        'NAME': 'MY_DATABASE',\n        'SCHEMA': 'MY_SCHEMA',\n        'WAREHOUSE': 'MY_WAREHOUSE',\n        'USER': 'my_user',\n        'PASSWORD': 'my_password',\n        'ACCOUNT': 'my_account',\n        # Include 'OPTIONS' if you need to specify any other\n        # snowflake.connector.connect() parameters, documented at:\n        # https://docs.snowflake.com/en/user-guide/python-connector-api.html#connect\n        'OPTIONS': {\n            # Examples:\n            'role': 'MY_ROLE',\n            # To use native Okta authenticators:\n            # https://docs.snowflake.com/en/user-guide/admin-security-fed-auth-use#native-sso-okta-only\n            'authenticator': 'https://example.okta.com',\n            # To use private key authentication:\n            'private_key_file': '\u003cpath\u003e/rsa_key.p8',\n            'private_key_file_pwd': 'my_passphrase',\n        },\n    },\n}\n```\n\n## Persistent connections\n\nTo use persisent connections, set Django's [`CONN_MAX_AGE`](https://docs.djangoproject.com/en/stable/ref/databases/#persistent-connections)\nand Snowflake Python Connector's [`client_session_keep_alive`](https://docs.snowflake.com/en/sql-reference/parameters#client-session-keep-alive):\n\n```python\nDATABASES = {\n    'default': {\n        # ...\n        'CONN_MAX_AGE': None,\n        'OPTIONS': {\n            'client_session_keep_alive': True,\n        },\n    },\n}\n```\n\n## Notes on Django fields\n\n- Consistent with [Snowflake's convention](https://docs.snowflake.com/en/sql-reference/identifiers-syntax.html),\n  this backend uppercases all database identifiers (table names, column names,\n  etc.) unless they are quoted, e.g. `db_table='\"table_name\"'`.\n\n- Snowflake supports defining foreign key and unique constraints, however, it\n  doesn't enforce them. Thus, Django manages these constraints and `inspectdb`\n  detects them, but Django won't raise `IntegrityError` if they're violated.\n\n- Snowflake doesn't support indexes. Thus, Django ignores any indexes defined\n  on models or fields.\n\n- Snowflake doesn't support check constraints, so the various\n  `PositiveIntegerField` model fields allow negative values (though validation\n  at the form level still works).\n\n## Notes on Django QuerySets\n\n* Snowflake has\n  [limited support for subqueries](https://docs.snowflake.com/en/user-guide/querying-subqueries.html#types-supported-by-snowflake).\n\n* Valid values for `QuerySet.explain()`'s `format` parameter are `'json'`,\n  `'tabular'`, and `'text'`. The default is `'tabular'`.\n\n## Known issues and limitations\n\nThis list isn't exhaustive. If you run into a problem, consult\n`django_snowflake/features.py` to see if a similar test is skipped. Please\n[create an issue on GitHub](https://github.com/Snowflake-Labs/django-snowflake/issues/new)\nif you encounter an issue worth documenting.\n\n* Snowflake doesn't support `last_insert_id` to retrieve the ID of a newly\n  created object. Instead, this backend issues the query\n  `SELECT MAX(pk_name) FROM table_name` to retrieve the ID. This is subject\n  to race conditions if objects are created concurrently. This makes this\n  backend inappropriate for use in web app use cases where multiple clients\n  could be creating objects at the same time. Further, you should not manually\n  specify an ID (e.g. `MyModel(id=1)`) when creating an object.\n\n* Due to snowflake-connector-python's [lack of VARIANT support](https://github.com/snowflakedb/snowflake-connector-python/issues/244),\n  some `JSONField` queries with complex JSON parameters [don't work](https://github.com/Snowflake-Labs/django-snowflake/issues/58).\n\n  For example, if `value` is a `JSONField`, this won't work:\n  ```python\n  \u003e\u003e\u003e JSONModel.objects.filter(value__k={\"l\": \"m\"})\n  ```\n  A workaround is:\n  ```python\n  \u003e\u003e\u003e from django.db.models.expressions import RawSQL\n  \u003e\u003e\u003e JSONModel.objects.filter(value__k=RawSQL(\"PARSE_JSON(%s)\", ('{\"l\": \"m\"}',)))\n  ```\n  In addition, ``QuerySet.bulk_update()`` isn't supported for `JSONField`.\n\n* Interval math where the interval is a column\n  [is not supported](https://github.com/Snowflake-Labs/django-snowflake/issues/27).\n\n* Interval math with a null interval\n  [crashes](https://github.com/Snowflake-Labs/django-snowflake/issues/26).\n\n## Troubleshooting\n\n### Debug logging\n\nTo troubleshoot issues with connectivity to Snowflake, you can enable\n[Snowflake Connector for Python's logging](https://docs.snowflake.com/en/developer-guide/python-connector/python-connector-example#logging)\nusing [Django's `LOGGING` setting](https://docs.djangoproject.com/en/stable/topics/logging/).\n\nThis is a minimal addition to Django's default `\"loggers\"` configuration that\nenables the connector's `DEBUG` logging:\n\n```python\nLOGGING = {\n    …\n    \"loggers\": {\n        …\n        \"snowflake.connector\": {\n            \"level\": \"DEBUG\",\n            \"handlers\": [\"console\"],\n        },\n    },\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflake-labs%2Fdjango-snowflake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnowflake-labs%2Fdjango-snowflake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflake-labs%2Fdjango-snowflake/lists"}