I'm a frequent user of the backslashes in a similar way to what zzzeek indicated in his answer. PEP8 is just a guideline, don't lose sleep over it when you violate it!
However, I also frequently use the type of formatting below, where I've stolen zzzeek's first example, mildly tweaked it, and reformatted:
q = Session.query(
Subkeyword.subkeyword_id,
Subkeyword.subkeyword_word,
)
q = q.filter_by(subkeyword_company_id=self.e_company_id) # first filter
q = q.filter_by(subkeyword_word=subkeyword_word) # 2nd filter
q = q.filter_by(subkeyword_active=True)
if filter_by_foo:
q = q.filter(Subkeyword.foo == True)
# Run the query (I usually wrap in a try block)...
subkeyword = q.one()
The repeated reassignment to q seems kind of nasty at first, but I've gotten over it. The performance impact is effectively nil. A big advantage with this way is that you can mix in both trailing comments and comment lines to document your queries (as I've done with the useless additions above). Chaining lines with backslashes limits you here.
This way of formatting is particularly clean when formulating massive queries with tonnes of logic-triggered modifications, embedded scalar selects, etc.
As another example, I have a fairly large (> 150 lines) CTE query I'm generating in SQLAlchemy that has a lot of mixed logic, aliasing, and labeling (which is essential for readability of the generated query) that mixes both methods. A seriously reduced (and mangled) version of it starts something like below:
cte_init = session.\
query(
child1.foo.label("child1_foo"),
sa.literal(1).label("indent"), # can comment on non-slashed lines
child2.bar.label("child2bar"),
#comments between non-slashed lines ok, too
sa.func.MAX(toplevel.baz).label("max_baz"),
).\
select_from(top_level).\
join(child1,
child1.id == toplevel.fk_child1_id).\
join(child2.
child2.id == toplevel.fk_child2.id).\
filter(top_level.name == "bogus").\
cte(name = "cte", recursive = True)
if(use_filter_x):
cte_init = cte_init.filter_by(x = "whatever")
# etc (no, the above doesn't make any sense)...
In general, if you make sure to lead your lines off with the new operations (like many common SQL formatting schemes do), it stays quite readable. Don't be afraid of newlines within brackets, either.