In [19]: def show_sql(query):
: clauses = query._get_sql_clause()
: return 'SELECT %s %s' % (', '.join(clauses[0]),
clauses[1])
:
In [21]: show_sql(Page.objects.all())
Out[21]: 'SELECT "main_page"."id", "main_page"."title",
"main_page"."slug", "main_page"."content" F
I need to translate django db-api query code like
modelobject.objects.all() to a raw SQL from a shell, is it possible
without using connection.queries (which is logging all SQL - i just
need one for a particular line of code)
--~--~-~--~~~---~--~~
You received this
2 matches
Mail list logo