Python论坛  - 讨论区

标题:[python-chinese] Djiango 中如何打出SQL

2007年07月02日 星期一 11:34

Neo Chen openunix在163.com
星期一 七月 2 11:34:24 HKT 2007

ÎÒÏëÖªµÀËûµÄORMÉú³ÉµÄSQLÊÇʲô??

Èç:
Entry.objects.all()[5:10]

ÎÒÏëÖªµÀËûÊÇÓÃSQL ʵÏÖµÄOFFSET 5 LIMIT 5,»¹ÊǼǵÃÈ«È¡»Øºó,ÔÚÊý×éÖÐʵÏÖµÄ.

Homepage: http://www.netkiller.org.cn
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070702/6d05bf83/attachment.htm 
-------------- 下一部分 --------------
Ò»¸ö·ÇÎı¾¸½¼þ±»Çå³ý...
·¢ÐÅÈË: %(who)s
Ö÷Ìâ: %(subject)s
ÈÕÆÚ: %(date)s
´óС: 1325
Url: http://python.cn/pipermail/python-chinese/attachments/20070702/6d05bf83/attachment.bin 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月02日 星期一 17:16

天天向上 tiananlw在gmail.com
星期一 七月 2 17:16:43 HKT 2007

最简单的方法是 在Python25\Lib\site-packages\django\db\models\query.py中的第181句后面加入:
print "SELECT " + (self._distinct and "DISTINCT " or "") + ",".join(select)
+ sql, params
这样,每次执行数据库操作,都能在控制台中看到SQL语句

不过,会出好多的,眼睛会疼一点:)



在07-7-2,Neo Chen <openunix at 163.com> 写道:
>
>  我想知道他的ORM生成的SQL是什么??
>
> 如:
> Entry.objects.all()[5:10]
>
> 我想知道他是用SQL 实现的OFFSET 5 LIMIT 5,还是记得全取回后,在数组中实现的.
>
> Homepage: http://www.netkiller.org.cn
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070702/11ba4e55/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月02日 星期一 19:27

黄毅 yi.codeplayer在gmail.com
星期一 七月 2 19:27:57 HKT 2007

django.db.connection.queries

On 7/2/07, Neo Chen <openunix at 163.com> wrote:
>
>  我想知道他的ORM生成的SQL是什么??
>
> 如:
> Entry.objects.all()[5:10]
>
> 我想知道他是用SQL 实现的OFFSET 5 LIMIT 5,还是记得全取回后,在数组中实现的.
>
> Homepage: http://www.netkiller.org.cn
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


-- 
http://codeplayer.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070702/8fd4cdb8/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月03日 星期二 10:41

haur hekun06在gmail.com
星期二 七月 3 10:41:47 HKT 2007

Äĸö¿ØÖÆ̨ѽ?ÈçºÎÅäż ....

ÔÚ07-7-2£¬ÌìÌìÏòÉÏ <tiananlw在gmail.com> дµÀ£º
>
> ×î¼òµ¥µÄ·½·¨ÊÇ ÔÚPython25\Lib\site-packages\django\db\models\query.pyÖеĵÚ181¾äºóÃæ¼ÓÈ룺
> print "SELECT " + (self._distinct and "DISTINCT " or "") +
> ",".join(select) + sql, params
> ÕâÑù£¬Ã¿´ÎÖ´ÐÐÊý¾Ý¿â²Ù×÷£¬¶¼ÄÜÔÚ¿ØÖÆ̨Öп´µ½SQLÓï¾ä
>
> ²»¹ý£¬»á³öºÃ¶àµÄ£¬ÑÛ¾¦»áÌÛÒ»µã£º£©
>
>
>
> ÔÚ07-7-2£¬Neo Chen <openunix在163.com> дµÀ£º
> >
> >  ÎÒÏëÖªµÀËûµÄORMÉú³ÉµÄSQLÊÇʲô??
> >
> > Èç:
> > Entry.objects.all()[5:10]
> >
> > ÎÒÏëÖªµÀËûÊÇÓÃSQL ʵÏÖµÄOFFSET 5 LIMIT 5,»¹ÊǼǵÃÈ«È¡»Øºó,ÔÚÊý×éÖÐʵÏÖµÄ.
> >
> > Homepage: http://www.netkiller.org.cn
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070703/09b8da82/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月03日 星期二 11:22

Tian askfor在gmail.com
星期二 七月 3 11:22:38 HKT 2007

manualÉÏ˵¹ýµÄ¡£
²»¹ý²»¼ÇµÃÔÚÄÄÕÂÁË¡£

On 7/3/07, haur <hekun06在gmail.com> wrote:
>
> Äĸö¿ØÖÆ̨ѽ?ÈçºÎÅäż ....
>
> ÔÚ07-7-2£¬ÌìÌìÏòÉÏ <tiananlw在gmail.com> дµÀ£º
> >
> > ×î¼òµ¥µÄ·½·¨ÊÇ
> > ÔÚPython25\Lib\site-packages\django\db\models\query.pyÖеĵÚ181¾äºóÃæ¼ÓÈ룺
> > print "SELECT " + (self._distinct and "DISTINCT " or "") +
> > ",".join(select) + sql, params
> > ÕâÑù£¬Ã¿´ÎÖ´ÐÐÊý¾Ý¿â²Ù×÷£¬¶¼ÄÜÔÚ¿ØÖÆ̨Öп´µ½SQLÓï¾ä
> >
> > ²»¹ý£¬»á³öºÃ¶àµÄ£¬ÑÛ¾¦»áÌÛÒ»µã£º£©
> >
> >
> >
> > ÔÚ07-7-2£¬Neo Chen < openunix在163.com> дµÀ£º
> > >
> > >  ÎÒÏëÖªµÀËûµÄORMÉú³ÉµÄSQLÊÇʲô??
> > >
> > > Èç:
> > > Entry.objects.all()[5:10]
> > >
> > > ÎÒÏëÖªµÀËûÊÇÓÃSQL ʵÏÖµÄOFFSET 5 LIMIT 5,»¹ÊǼǵÃÈ«È¡»Øºó,ÔÚÊý×éÖÐʵÏÖµÄ.
> > >
> > > Homepage: http://www.netkiller.org.cn
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > > python-chinese-request在lists.python.cn
> > > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> > >
> > >
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070703/60a7eda1/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年07月03日 星期二 11:57

limodou limodou在gmail.com
星期二 七月 3 11:57:11 HKT 2007

On 7/3/07, Tian <askfor在gmail.com> wrote:
> manual上说过的。
> 不过不记得在哪章了。
>
FAQ
-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号