python连接mysql的问题

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

python连接mysql的问题

realfun
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 [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: python连接mysql的问题

小晨
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 <[hidden email]> 写道:
1. 我用的是<a href="http://mysql-python.sourceforge.net/MySQLdb.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mysql-python.sourceforge.net/MySQLdb.html, 大家都用这个吗?
2. 我看mysql书上提到默认值和auto_increment的值,但是我用mysqldb的execute去insert一行的时候,总出错,所以有两个小问题:
不知道怎么才能传个NULL给mysql?
怎么才能让timestamp的属性自动存储为当前时间?我试过"NOW()", "NULL", 0, 都不行。
mysql-python自带的文档太简略了,啥也没查到

有没有熟悉的帮帮忙哈。

--
<a href="http://www.2maomao.com/blog" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.2maomao.com/blog

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank">http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: python连接mysql的问题

realfun
我试过了,在bluehost.com的控制台上,要把默认值设成CURRENT_TIMESTAMP才行

在08-1-28,小晨 <[hidden email]> 写道:
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 <[hidden email]> 写道:
1. 我用的是<a href="http://mysql-python.sourceforge.net/MySQLdb.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mysql-python.sourceforge.net/MySQLdb.html, 大家都用这个吗?
2. 我看mysql书上提到默认值和auto_increment的值,但是我用mysqldb的execute去insert一行的时候,总出错,所以有两个小问题:
不知道怎么才能传个NULL给mysql?
怎么才能让timestamp的属性自动存储为当前时间?我试过"NOW()", "NULL", 0, 都不行。
mysql-python自带的文档太简略了,啥也没查到

有没有熟悉的帮帮忙哈。

--
<a href="http://www.2maomao.com/blog" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.2maomao.com/blog

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a href="http://python.cn/mailman/listinfo/python-chinese" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank">http://python.cn/mailman/listinfo/python-chinese



--
http://www.2maomao.com/blog
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: python连接mysql的问题

赵威-2
In reply to this post by realfun
realfun,您好!
 
  貌似这个也有限制?
 
======== 2008-01-28 10:56:19 您在来信中写道: ========
 
我试过了,在bluehost.com的控制台上,要把默认值设成CURRENT_TIMESTAMP才行

在08-1-28,小晨 <[hidden email]> 写道:
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 <[hidden email]> 写道:
1. 我用的是<A onclick="return top.js.OpenExtLink(window,event,this)" href="http://mysql-python.sourceforge.net/MySQLdb.html" target=_blank>http://mysql-python.sourceforge.net/MySQLdb.html, 大家都用这个吗?
2. 我看mysql书上提到默认值和auto_increment的值,但是我用mysqldb的execute去insert一行的时候,总出错,所以有两个小问题:
不知道怎么才能传个NULL给mysql?
怎么才能让timestamp的属性自动存储为当前时间?我试过"NOW()", "NULL", 0, 都不行。
mysql-python自带的文档太简略了,啥也没查到

有没有熟悉的帮帮忙哈。

--
<A onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.2maomao.com/blog" target=_blank>http://www.2maomao.com/blog

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <A onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target=_blank>http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <A onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target=_blank>http://python.cn/mailman/listinfo/python-chinese



--
http://www.2maomao.com/blog

= = = = = = = = = = = = = = = = = = = = = =

        致
礼!

 
              赵威
              [hidden email]
               2008-01-28
 

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese
Reply | Threaded
Open this post in threaded view
|

Re: python连接mysql的问题

realfun
不知道你说的"这个也有限制"指的是什么。

在08-1-28,赵威 <[hidden email]> 写道:
realfun,您好!
 
  貌似这个也有限制?
 
======== 2008-01-28 10:56:19 您在来信中写道: ========
 
我试过了,在bluehost.com的控制台上,要把默认值设成CURRENT_TIMESTAMP才行

在08-1-28,小晨 <[hidden email]> 写道:
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 <[hidden email]> 写道:
1. 我用的是<a href="http://mysql-python.sourceforge.net/MySQLdb.html" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://mysql-python.sourceforge.net/MySQLdb.html, 大家都用这个吗?
2. 我看mysql书上提到默认值和auto_increment的值,但是我用mysqldb的execute去insert一行的时候,总出错,所以有两个小问题:
不知道怎么才能传个NULL给mysql?
怎么才能让timestamp的属性自动存储为当前时间?我试过"NOW()", "NULL", 0, 都不行。
mysql-python自带的文档太简略了,啥也没查到

有没有熟悉的帮帮忙哈。

--
<a href="http://www.2maomao.com/blog" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.2maomao.com/blog

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a href="http://python.cn/mailman/listinfo/python-chinese" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://python.cn/mailman/listinfo/python-chinese


_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a href="http://python.cn/mailman/listinfo/python-chinese" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://python.cn/mailman/listinfo/python-chinese



--
<a href="http://www.2maomao.com/blog" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.2maomao.com/blog

= = = = = = = = = = = = = = = = = = = = = =

        致
礼!

 
              赵威
              [hidden email]
               2008-01-28
 

_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://python.cn/mailman/listinfo/python-chinese" target="_blank">http://python.cn/mailman/listinfo/python-chinese



--
http://www.2maomao.com/blog
_______________________________________________
python-chinese
Post: send [hidden email]
Subscribe: send subscribe to [hidden email]
Unsubscribe: send unsubscribe to  [hidden email]
Detail Info: http://python.cn/mailman/listinfo/python-chinese