siuba icon indicating copy to clipboard operation
siuba copied to clipboard

AttributeError: module 'sqlalchemy.sql.base' has no attribute 'ImmutableColumnCollection'

Open christophscheuch opened this issue 2 years ago • 1 comments

I tried to replicate the minimal example from the website using an in-memory SQLite database:

from siuba import _, tbl, group_by, filter
from siuba.data import cars

# setup ----
from sqlalchemy import create_engine

engine = create_engine("sqlite:///:memory:")
cars.to_sql("cars", engine, index=False)

# analysis ----
(tbl(engine, "cars")
    >> group_by(_.cyl)
    >> filter(_.mpg < _.mpg.mean())
)

I get the following error:

AttributeError: module 'sqlalchemy.sql.base' has no attribute 'ImmutableColumnCollection'

Also the direct import does not work as this chunk

from sqlalchemy.sql.base import ImmutableColumnCollection

returns

ImportError: cannot import name 'ImmutableColumnCollection' from 'sqlalchemy.sql.base'

I guess it is related to this recent commit where they renamend it to ReadOnlyColumnCollection: https://github.com/sqlalchemy/sqlalchemy/commit/4e754a8914a1c2c16c97bdf363d2e24bfa823730#diff-31621fcf3d90e3d9b15029c8dc1ccbf0b7c9f320a0d04471ec0e68ae02e4ec78L1502

I'm sorry in case I miss something completely obvious. I just discovered siuba and found it appealing as an experienced R, but unfortunately I did not get far yet :(

christophscheuch avatar Apr 12 '23 20:04 christophscheuch

@christophscheuch , it is because siuba is using an old version of sqlalchemy package. Try installing version 1.4.32 (pip install sqlalchemy==1.4.32). For me, that worked.

GitHunter0 avatar Aug 01 '23 00:08 GitHunter0