2

I need to implement a function that takes a lambda as the argument and queries the database. I use SQLAlchemy for ORM. Is there a way to pass the lambda, that my function receives, to SQLAlchemy to create a query?

Sincerely, Roman Prykhodchenko

1
  • Could you provide example of desired result? Its not too clear from the question itself. Commented Dec 17, 2010 at 13:38

1 Answer 1

2

I guess you want to filter the data with the lambda, like a WHERE clause? Well, no, functions nor lambdas cannot be turned into a SQL query. Sure, you could just fetch all the data and filter it in Python, but that completely defeats the purpose of the database.

You'll need to recreate the logic you put into the lambda with SQLAlchemy.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your answer. Yes, I did want to filter results with the lambda.

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.