You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the insert_rows function of the sqlite hook the generated parametrized sql query has an invalid syntax. It will generate queries with the %s placeholder which result in the following error:
Query: INSERT INTO example_table (col1, col2) VALUES (%s,%s)
Error:
sqlite3.OperationalError: near "%": syntax error
Stacktrace:
File "/home/airflow/.pyenv/versions/3.8.10/envs/airflow_3.8.10/lib/python3.8/site-packages/airflow/hooks/dbapi.py", line 307, in insert_rows
cur.execute(sql, values)
I replaced the placeholder with "?" in the _generate_insert_sql function DbApiHook as a test. This solved the issue.
What you expected to happen:
Every inherited method of the DbApiHook should work for the SqliteHook. Using the insert_rows method should generate the correct parametrized query and insert rows as expected.
How to reproduce it:
Create an instance of the SqliteHook
Use the insert_rows method of the SqliteHook
The text was updated successfully, but these errors were encountered:
Would you be willing to provide a fix for that @Bart-art ? That sounds like rather easy fix - good for first-time contribution. Happy to help with it if needed.
Apache Airflow version: 2.1.0
OS: Raspbian GNU/Linux 10 (buster)
Apache Airflow Provider versions: apache-airflow-providers-sqlite==1.0.2
Deployment: Virtualenv
What happened:
When using the insert_rows function of the sqlite hook the generated parametrized sql query has an invalid syntax. It will generate queries with the %s placeholder which result in the following error:
Query: INSERT INTO example_table (col1, col2) VALUES (%s,%s)
Error:
sqlite3.OperationalError: near "%": syntax error
Stacktrace:
File "/home/airflow/.pyenv/versions/3.8.10/envs/airflow_3.8.10/lib/python3.8/site-packages/airflow/hooks/dbapi.py", line 307, in insert_rows
cur.execute(sql, values)
I replaced the placeholder with "?" in the _generate_insert_sql function DbApiHook as a test. This solved the issue.
What you expected to happen:
Every inherited method of the DbApiHook should work for the SqliteHook. Using the insert_rows method should generate the correct parametrized query and insert rows as expected.
How to reproduce it:
The text was updated successfully, but these errors were encountered: