Snowflake-Labs / django-snowflake

MIT License
59 stars 15 forks source link

"The error was: too many values to unpack (expected 11)" while running inspectdb #84

Closed ClausSander closed 4 months ago

ClausSander commented 4 months ago

Hi,

I'm trying to perform the Django inspectdb command using my snowflake connection, but I get the following error:

> python manage.py inspectdb --database snowflake table_name
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
#   * Rearrange models' order
#   * Make sure each model has one field with primary_key=True
#   * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
#   * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
# Unable to inspect table 'table_name'
# The error was: too many values to unpack (expected 11)

I'm using:

The database connection in settings.py is configured like this:

DATABASES = {
    ...
    'snowflake': {
        'ENGINE': env("SNOWFLAKE_ENGINE"),
        'NAME': env("SNOWFLAKE_NAME"),
        'SCHEMA': env("SNOWFLAKE_SCHEMA"),
        'WAREHOUSE': env("SNOWFLAKE_WAREHOUSE"),
        'USER': env("SNOWFLAKE_USER"),
        'PASSWORD': env("SNOWFLAKE_PASSWORD"),
        'ACCOUNT': env("SNOWFLAKE_ACCOUNT"),
        'OPTIONS': {
            'role': env("SNOWFLAKE_ROLE"),
        },
    }
}

I am able to access the data using the Django Shell, so I know the the connection is working.

>>> from django.db import connections
>>> conn = connections['snowflake']
>>> cursor = conn.cursor()
>>> cursor.execute("SELECT * FROM table_name").fetchall()
[(...), (...), ...]

Am I missing something here? Thanks in advance.

timgraham commented 4 months ago

This will be fixed shortly, see #83.

ClausSander commented 4 months ago

Great, thanks!

timgraham commented 4 months ago

Please use django-snowflake 4.2.1, now available on PyPI.

ClausSander commented 4 months ago

It works now, thanks for the quick fix!