One major difference between what SQL does and what you can do in idiomatic python, in SQL, you tell the evaluator what information you are looking for, and it works out the most efficient way of retrieving that based on the structure of the data it holds. In python, you can only tell the interpreter how you want the data, there's no equivalent to a query planner.
That said, there are a few extra tools above and beyond list comprehensions that help alot.
First, use a structure that closely resembles the declarative nature of SQL. Many of them are builtins. map
, filter
, reduce
, zip
, all
, any
, sorted
, as well as the contents of the operator
, functools
and itertools
packages, all offer a fairly concise way of expressing data queries.