Skip to content
Advertisement

psycopg2 sql.SQL: Composed elements must be Composable

results in an error of

Given that composable is the base class, I’m not really sure what the error is because of. As far as I know it seems correct based on the examples from the docs. My sql_schema

one other idea I had was to wrap the non-datetime values in sql.Literal but then I run into the datetime issue.

Looking around, I’ve seen other people using different notation but it feels less “clean” which is definitely subjective but IDK.

Edit

Based on the comments from the answer, my updated script is

but I’m still running into the issue TypeError: Composed elements must be Composable, got 'lookup' instead

Advertisement

Answer

sql.SQL.join join a sequence of Composable but you are providing normal variable like string , list etc in values variable.

secondly i will suggest use placeholder for values in query then pass values to execute .

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement