Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqla.SQLAlchemyTarget.exist() won't work with SqlAlchemy 2.x version #3278

Open
jon-alamo opened this issue Feb 16, 2024 · 0 comments
Open

Comments

@jon-alamo
Copy link

Description

It seems sqla.py module is using old SqlAlchemy select interface in:

s = sqlalchemy.select([table]).where(sqlalchemy.and_(table.c.update_id == self.update_id,

which seems to be incompatible with SqlAlchemy 2.x according to:
https://docs.sqlalchemy.org/en/20/changelog/migration_14.html#change-5284


Details

Python version: 3.10.11

Package versions:

luigi==3.5.0
SQLAlchemy==2.0.27

Snippet to reproduce:

from luigi import build
from luigi.contrib.sqla import CopyToTable
from sqlalchemy import create_engine

engine = create_engine('sqlite:///test.db')


class TaskCopy(CopyToTable):
    connection_string = 'sqlite:///test.db'
    table = 'my_table'


if __name__ == '__main__':
    build([TaskCopy()], local_scheduler=True)

Error:

sqlalchemy.exc.ArgumentError: Column expression, FROM clause, or other columns clause element expected, got [Table('table_updates', MetaData(), Column('update_id', String(length=128), table=<table_updates>, primary_key=True, nullable=False), Column('target_table', String(length=128), table=<table_updates>), Column('inserted', DateTime(), table=<table_updates>, default=ScalarElementColumnDefault(datetime.datetime(2024, 2, 16, 11, 39, 6, 28774))), schema=None)]. Did you mean to say select(Table('table_updates', MetaData(), Column('update_id', String(length=128), table=<table_updates>, primary_key=True, nullable=False), Column('target_table', String(length=128), table=<table_updates>), Column('inserted', DateTime(), table=<table_updates>, default=ScalarElementColumnDefault(datetime.datetime(2024, 2, 16, 11, 39, 6, 28774))), schema=None))?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant