spotify / luigi

Luigi is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in.
Apache License 2.0
17.71k stars 2.39k forks source link

Fix for sqlalchemy 2 and text upgrades #3267

Open pjaol opened 8 months ago

pjaol commented 8 months ago

Description

Quick fix for task history logging and sqlalchemy 2.x

Motivation and Context

Using sqlalchemy 2.x breaks luigid if task history is enabled e.g.

[task_history]
db_connection = sqlite:///./log/luigi-task-hist.sqlite

Results in luigid exiting

File ".../env/lib/python3.11/site-packages/luigi/db_task_history.py", line 271, in _upgrade_schema
    for i in conn.execute('PRAGMA table_info(task_parameters);').fetchall():
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../env/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1414, in execute
    raise exc.ObjectNotExecutableError(statement) from err
sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'PRAGMA table_info(task_parameters);'

This is because sqlalchemy requires a sqlalchemy.text object vs string in conn.execute

Have you tested this? If so, how?

Tested locally with sqlite3 and sqlalchemy 2.0.23 and luigi 3.4.0

pjaol commented 8 months ago

Hey @dlstadther what can I do to help move this forward? I'm not sure what to look at to increase the code cov test