the example:
[yorks@web-db]$ python
Python 2.6.6 (r266:84292, May 1 2012, 13:52:17)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import web
>>> db=web.database(dbn='mysql', host='127.0.0.1', port=3306,
user='db_user', passwd='!mySql$', db='mysql')
>>> res = db.query("select * from host;")
*0.0 (1): select * from host;* # ----------------> this stderr msg.
>>> type(res)
<type 'instance'>
>>> print res
<web.utils.IterBetter instance at 0x7f55b4e062d8>
>>> len(res)
0
>>>
[yorks@web-db]$ mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 108352 to server version: 4.1.22-standard-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> desc host;
+-----------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------------+------+-----+---------+-------+
| Host | char(60) | | PRI | | |
| Db | char(64) | | PRI | | |
| Select_priv | enum('N','Y') | | | N | |
| Insert_priv | enum('N','Y') | | | N | |
| Update_priv | enum('N','Y') | | | N | |
| Delete_priv | enum('N','Y') | | | N | |
| Create_priv | enum('N','Y') | | | N | |
| Drop_priv | enum('N','Y') | | | N | |
| Grant_priv | enum('N','Y') | | | N | |
| References_priv | enum('N','Y') | | | N | |
| Index_priv | enum('N','Y') | | | N | |
| Alter_priv | enum('N','Y') | | | N | |
| Create_tmp_table_priv | enum('N','Y') | | | N | |
| Lock_tables_priv | enum('N','Y') | | | N | |
+-----------------------+---------------+------+-----+---------+-------+
14 rows in set (0.00 sec)
mysql> select * from host;
Empty set (0.00 sec)
mysql>
sincerely,
在 2013年11月17日星期日UTC+8下午12时30分16秒,Mugong Jian写道:
>
> use "web.db.query " for a "select" sql will not return a NULL, can you
> give the err mesage and you table struct,
> need more detail.
>
> On Wednesday, November 6, 2013 5:55:10 PM UTC+8, you yang wrote:
>>
>> I'm using web.db.query to select from MySQL DB.
>> But, when the result is None, the this function will output the stderr
>> msg:
>> """
>> 0.0 (1): select * from `notify` where `end_time`=0 and
>> ((`start_time`+`alert_seconds`) < unix_timestamp());
>> """
>>
>> and my function is:
>> """
>> self.db = web.database(dbn='mysql', host='myhost.internal',
>> port=3306, user='db_user11', passwd='*******', db='DBDB')
>> def get_unfinish_notify(self):
>> try:
>> res = self.db.query("select * from `notify` where
>> `end_time`=0 and ((`start_time`+`alert_seconds`) < unix_timestamp());")
>> except:
>> res = False
>> return res
>> """
>> -
>> Thanks
>>
>
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.