Welcome to the Treehouse Community
Looking to learn something new?
Is there an advantage to the Peewee syntax over standard SQL?
If I had a choice, I'd prefer a database library that connects to SQLite or what have you and has an execute() method that you feed standard SQL statements. I just find the Peewee syntax cumbersome and convoluted and imagine that in a business context knowledge of ANSI SQL statement construction and usage would be preferable.
I'm the author of peewee so I'm of course biased, but just wanted to say that Peewee queries generally tend to be quite close to their SQL analogues. Compare them to Django and you'll see what I mean. Yes, for simple queries it can be more characters, but using an ORM like peewee has quite a few benefits:
- Re-use query fragments
- Build queries programmatically, piece by piece without nasty string munging
- Leverage python's parser to ensure your queries are valid (i.e., it's near impossible to forget a parentheses, omit a comma, etc).
- Safe against SQL injection
- Probably other stuff, too.
Kenneth LoveTreehouse Guest Teacher
I don't know any professional Python (or Ruby, PHP, Java, etc) developers that write pure SQL. There's simply no reason to expose yourself to that level of risk or complication when tools have been created to make it easier, safer, and, generally, smarter. A good ORM will generally write as good or better queries than a human will.