Python论坛  - 讨论区

标题:[python-chinese] python连接mysql的问题

2008年01月27日 星期日 23:35

realfun realfun在gmail.com
星期日 一月 27 23:35:55 HKT 2008

1. ÎÒÓõÄÊÇhttp://mysql-python.sourceforge.net/MySQLdb.html, ´ó¼Ò¶¼ÓÃÕâ¸öÂð£¿
2.
ÎÒ¿´mysqlÊéÉÏÌᵽĬÈÏÖµºÍauto_incrementµÄÖµ£¬µ«ÊÇÎÒÓÃmysqldbµÄexecuteÈ¥insertÒ»ÐеÄʱºò£¬×ܳö´í£¬ËùÒÔÓÐÁ½¸öСÎÊÌ⣺
²»ÖªµÀÔõô²ÅÄÜ´«¸öNULL¸ømysql£¿
Ôõô²ÅÄÜÈÃtimestampµÄÊôÐÔ×Ô¶¯´æ´¢Îªµ±Ç°Ê±¼ä?ÎÒÊÔ¹ý"NOW()", "NULL", 0£¬ ¶¼²»ÐС£
mysql-python×Ô´øµÄÎĵµÌ«¼òÂÔÁË£¬É¶Ò²Ã»²éµ½

ÓÐûÓÐÊìϤµÄ°ï°ïæ¹þ¡£

-- 
http://www.2maomao.com/blog
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080127/9b126fe0/attachment.html 

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

2008年01月28日 星期一 10:44

小晨 lichengiggs在gmail.com
星期一 一月 28 10:44:51 HKT 2008

timestamp的默认值是插入数据库的时间吧,不用指定都可以的。

A TIMESTAMP column is useful for recording the date and time of an INSERT or
UPDATE operation. By default, the first TIMESTAMP column in a table is
automatically set to the date and time of the most recent operation if you
do not assign it a value yourself. You can also set any TIMESTAMP column to
the current date and time by assigning it a NULL value.



在08-1-27,realfun <realfun在gmail.com> 写道:
>
> 1. 我用的是http://mysql-python.sourceforge.net/MySQLdb.html, 大家都用这个吗?
> 2.
> 我看mysql书上提到默认值和auto_increment的值,但是我用mysqldb的execute去insert一行的时候,总出错,所以有两个小问题:
> 不知道怎么才能传个NULL给mysql?
> 怎么才能让timestamp的属性自动存储为当前时间?我试过"NOW()", "NULL", 0, 都不行。
> mysql-python自带的文档太简略了,啥也没查到
>
> 有没有熟悉的帮帮忙哈。
>
> --
> http://www.2maomao.com/blog
> _______________________________________________
> 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/20080128/a016bbde/attachment.html 

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

2008年01月28日 星期一 10:56

realfun realfun在gmail.com
星期一 一月 28 10:56:19 HKT 2008

ÎÒÊÔ¹ýÁË£¬ÔÚbluehost.comµÄ¿ØÖÆ̨ÉÏ£¬Òª°ÑĬÈÏÖµÉè³ÉCURRENT_TIMESTAMP²ÅÐÐ

ÔÚ08-1-28£¬Ð¡³¿ <lichengiggs在gmail.com> дµÀ£º
>
> timestampµÄĬÈÏÖµÊDzåÈëÊý¾Ý¿âµÄʱ¼ä°É£¬²»ÓÃÖ¸¶¨¶¼¿ÉÒԵġ£
>
> A TIMESTAMP column is useful for recording the date and time of an INSERTor
> UPDATE operation. By default, the first TIMESTAMP column in a table is
> automatically set to the date and time of the most recent operation if you
> do not assign it a value yourself. You can also set any TIMESTAMP column
> to the current date and time by assigning it a NULL value.
>
>
>
> ÔÚ08-1-27£¬realfun <realfun在gmail.com> дµÀ£º
> >
> > 1. ÎÒÓõÄÊÇhttp://mysql-python.sourceforge.net/MySQLdb.html, ´ó¼Ò¶¼ÓÃÕâ¸öÂð£¿
> > 2.
> > ÎÒ¿´mysqlÊéÉÏÌᵽĬÈÏÖµºÍauto_incrementµÄÖµ£¬µ«ÊÇÎÒÓÃmysqldbµÄexecuteÈ¥insertÒ»ÐеÄʱºò£¬×ܳö´í£¬ËùÒÔÓÐÁ½¸öСÎÊÌ⣺
> > ²»ÖªµÀÔõô²ÅÄÜ´«¸öNULL¸ømysql£¿
> > Ôõô²ÅÄÜÈÃtimestampµÄÊôÐÔ×Ô¶¯´æ´¢Îªµ±Ç°Ê±¼ä?ÎÒÊÔ¹ý"NOW()", "NULL", 0£¬ ¶¼²»ÐС£
> > mysql-python×Ô´øµÄÎĵµÌ«¼òÂÔÁË£¬É¶Ò²Ã»²éµ½
> >
> > ÓÐûÓÐÊìϤµÄ°ï°ïæ¹þ¡£
> >
> > --
> > http://www.2maomao.com/blog
> > _______________________________________________
> > 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
>



-- 
http://www.2maomao.com/blog
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20080128/d8a81c7c/attachment.html 

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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号