Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a raw sql method

  • Loading branch information...
commit a5ec7bb90b1882db95c6f4eae94ea373f7f6a50f 1 parent 3aa06e8
@coleifer authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 peewee.py
View
4 peewee.py
@@ -2089,3 +2089,7 @@ def dfs(model):
for m in sorted(models, key=names, reverse=True):
dfs(m)
return list(reversed(ordering)) # want parents first in output ordering
+
+def raw_sql(query):
+ db = query.model_class._meta.database
+ return query.sql(db.get_compiler())

2 comments on commit a5ec7bb

@kevinisaac

Can someone please give an example of how to use this helper function?

@coleifer
Owner

query = MyModel.select()
print raw_sql(query)

Please sign in to comment.
Something went wrong with that request. Please try again.