0

I am trying to use the sqlalchemy 'Delete' expression following this article:
How to delete rows from a table using an SQLAlchemy query without ORM?

My problem is that the actual where clause (the column names on which to filter) needs to be passed dynamically. But in the example, I see that the column names are not dynamic, only the filter values. Am I missing something?

Basically, the below query filters on the column 'retired'. I want to pass 'retired' dynamically.:

  table_name = Table('address',metadata,autoload=True)
  d = table_name.delete().where(table_name.c.retired == 1)
  d.execute()
2
  • It's not clear how dynamic your columns are. Please provide more details about what the query looks like. Commented Jul 2, 2021 at 15:15
  • Do you mean using something like table_name.columns["retired"] instead of table_name.c.retired ? Commented Jul 2, 2021 at 16:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.