'django to snowflake connection and running ORM queries

I am looking to shift out of Postgres to SnowFlake as some of my features require run time analysis which is faster in Snowflake.

I could only get the Python connector API for Snowflake which would require me to create raw queries instead of Djago ORM queries.

Is there anyway we can connect to Snowflake using Django and execute the same Django ORM queries on Snowflake.

I saw this old post How to query this (snow flake) data schema in django

But couldn't find how to set up a django connection with Snowflake.



Solution 1:[1]

The snowflake-sqlalchemy package provides connecting from sqlalchemy to Snowflake.

Another python snowflake low-level connector is documented here

I never tried either of them though.

Solution 2:[2]

2022 update: There's now a Snowflake backend for Django funded by Snowflake customers and implemented by Django's Tim Graham:

From their docs:

Install and usage

Use the version of django-snowflake that corresponds to your version of Django. For example, to get the latest compatible release for Django 3.2.x:

pip install django-snowflake==3.2.*

The minor release number of Django doesn't correspond to the minor release number of django-snowflake. Use the latest minor release of each.

Configure the Django DATABASES setting similar to this:

DATABASES = {
    'default': {
        'ENGINE': 'django_snowflake',
        'NAME': 'MY_DATABASE',
        'SCHEMA': 'MY_SCHEME',
        'WAREHOUSE': 'MY_WAREHOUSE',
        'USER': 'my_user',
        'PASSWORD': 'my_password',
        'ACCOUNT': 'my_account',
    },
}

Some of the discussion while implementing it:


(Trying to mark this question/answer as duplicate of https://stackoverflow.com/a/70935067/132438)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shadi
Solution 2 Felipe Hoffa