Thursday, July 31, 2008

Automatically convert data type when using MySQLdb

Add following lines:

from MySQLdb.constants import FIELD_TYPE

def DateTime2string(object):
return str(object)

conv_dict = MySQLdb.converters.conversions
conv_dict[FIELD_TYPE.DATETIME] = DateTime2string

conn = MySQLdb.connect (host = 'host',
port = 'port',
user = 'user',
passwd = 'passwd',
db = 'db',
conv = conv_dict
)
Then the cursor will automatically convert all fields of DateTime type in resultset into str for you.
This trick was inspired by this post which unfortunately didn't work for me.

Saturday, April 19, 2008

Tuesday, February 28, 2006

How to modify the configuration of OPENT

The philosophy of OPNET configuration is that they keep all the config info organised as a database.So whatever you want to change, go to the "edit"->"preference", find the corresponding item and modify it.For example,a.the default setting of OPNET is to close on each saving editting. that is rediculous,because I always press "ctrl_S" after I make a modification. So, change it in "Edit"-->"Preference":find item "process_edit_close_on_save" and change it into "false"b.in "Preference""vudoc_prog" setting the path of the Acrobat reader.

Sunday, February 26, 2006

sunrise

 Posted by Picasa

Today is the birthday of this blog!

:)