使用Django的django-extensions运行IPython Notebook时隐藏SQL语句 [英] Hide SQL statements when running IPython notebook with Django's django-extensions
问题描述
我正在使用Django的django-extensions运行可访问Django模型的iPython笔记本(如此处详细说明
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:
我可以隐藏此SQL吗?它是如此庞大,以致有时无法显示.
Can I hide this SQL? It's so voluminous it makes the display unusable at times.
推荐答案
使用最新版本,您可以使用
with recent version, you could use
%%capture variable
the code
将stdout和stderr捕获到一个变量中 添加--no-stdout标志
to capture stdout and stderr into a variable adding the --no-stdout flag
%%capture --no-stdout variable
不会捕获标准输出,因此将其显示.
wont capture stdout, thus displaying it.
另外,请优先选择IPython(上卡塞I), ipython被接受了,但是要避免使用iPython
Also, please, IPython (upper casse I) preferably, ipython accepted, but try to avoid iPython
这篇关于使用Django的django-extensions运行IPython Notebook时隐藏SQL语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!