Hide SQL statements when running IPython notebook with Django's django-extensions

无人久伴 提交于 2019-12-24 00:47:28

问题


I'm using Django's django-extensions to run an iPython notebook with access to the Django models (as detailed here http://andrewbrookins.com/python/using-ipython-notebook-with-django/). When I make model queries, the notebook shows the underlying SQL queries executed by Django, like so:

Can I hide this SQL? It's so voluminous it makes the display unusable at times.


回答1:


with recent version, you could use

%%capture variable
the code

to capture stdout and stderr into a variable adding the --no-stdout flag

%%capture --no-stdout variable

wont capture stdout, thus displaying it.

Also, please, IPython (upper casse I) preferably, ipython accepted, but try to avoid iPython



来源:https://stackoverflow.com/questions/14738163/hide-sql-statements-when-running-ipython-notebook-with-djangos-django-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!