Uh, neither? A good query builder library, though not one that tries to excuse you from knowing actual SQL. If you try writing SQL by hand, you _will_ eventually mess up and introduce SQL injection somewhere.
There are some tools for that in other languages (Squirrel in Go, Arel - the thing backing Active Record), but I've found SQL Alchemy the most comfortable. Access to schema data is something that even I, mostly sceptical of "proper" ORMs, find really useful.