I chose a unique approach, which is to create a new programming language, that compiles to SQL. That way, it could access all of the good that SQL has to offer (and there is plenty), but with all the features of a modern language, and without the design limitations of ORMs. It allowed me to add sorely missed features like first-class functions, modules, and type safety.
I built Preql in Python, which allows for a very smooth interface between the two. For parsing, I used a library called Lark, which I created three years ago. I also created a new library called Runtype, which proved very helpful for writing the compiler.
While Preql is still in its early stages, I'm very proud of what I've accomplished so far, and I hope you'll decide to take it out for a spin.