7
将Python datetime.datetime对象插入MySQL
我在MySQL表中有一个日期列。我想在datetime.datetime()此列中插入一个对象。我应该在execute语句中使用什么? 我努力了: now = datetime.datetime(2009,5,5) cursor.execute("INSERT INTO table (name, id, datecolumn) VALUES (%s, %s , %s)",("name", 4,now)) 我收到以下错误消息:"TypeError: not all arguments converted during string formatting" 应该用什么代替%s?