From: bruce on 11 Aug 2010 11:08 hi... using python v2.6, using the mysqldb lib the test tbl looks like: DROP TABLE IF EXISTS `functionError_TBL`; CREATE TABLE `functionError_TBL` ( `parentFunction` varchar(100) NOT NULL default '', `currentFunction` varchar(100) NOT NULL default '', `parentFunctionID` int(10) NOT NULL default 0, `errorStatus` int(1) NOT NULL default 0, `clientServerUUID` varchar(100) NOT NULL default '', `processTime` timestamp NOT NULL default 0, `CollegeID` int(10) NOT NULL default 0, `CrawlID` varchar(200) NOT NULL default '', `CollegeName` varchar(200) NOT NULL default '', `CollegeAbbrv` varchar(200) NOT NULL default '', . . the test script looks like . . tlist= [(1, 1, 1281502771)] ins="insert into functionError_TBL " ins=ins+"(errorStatus, CollegeID, processTime)" ins=ins+" values " ins=ins+" (%s,%s, from_unixtime(%s))" db.executemany (ins, tlist) if the parameter is : (%s,%s, from_unixtime(%s))" it appears to work, data is inserted correctly... if the parameters are changed to (%s,from_unixtime(%s), %s)" along with the corresponding insert portion, and the test list, an error is generated.. this implies that something is going on with the use of the "from_unixtime" that i don't fully understand.. thoughts/pointers/comments... thanks thoughts on how to resolve this would be greatly appreciated. thanks
From: bruce on 11 Aug 2010 13:29 hey dennis... umm.. given that i'm building the ins var/string to insert into the execute... i can't just place the triple quotes around it.. are you saying that the execute should have quotes placed around it within the execute so it would be something like execute("\""+sel""\""... or are you saying that within python i can just extend the line for the "sel" on multiple lines.. as to the err. i'm getting a " >>> Warning: Data truncated for column it appears that if i place the >>from_unixtime(%s) << at the end of the paramaters, then everything works.. but if i place it within the "%s" block.. the error is generated. I'm assuming there's some way to wrap the from_unixtime(%s) so it could be used as %s,%s,%s, from_unixtime(%s), %s, %s,... in checking the docs/spec.. i didn't see anything that discussed this... thanks > ins = """insert into functionError_TBL > (errorStatus, CollegeID, processTime) > values (%s, %s, from_unixtime(%s) )""" > On Wed, Aug 11, 2010 at 9:53 AM, Dennis Lee Bieber <wlfraed(a)ix.netcom.com> wrote: > On Wed, 11 Aug 2010 08:08:21 -0700, bruce <badouglas(a)gmail.com> > declaimed the following in gmane.comp.python.general: > > >> tlist= [(1, 1, 1281502771)] >> >> ins="insert into functionError_TBL " >> ins=ins+"(errorStatus, CollegeID, processTime)" >> ins=ins+" values " >> ins=ins+" (%s,%s, from_unixtime(%s))" > > Without examining the rest of the problem, the above sequence can be > cleaned up by using triple quotes... > > ins = """insert into functionError_TBL > (errorStatus, CollegeID, processTime) > values (%s, %s, from_unixtime(%s) )""" > >> >> along with the corresponding insert portion, and the test list, an >> error is generated.. >> > What error? You've failed to post the most important part.... EXACTLY > what the system reports... > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed(a)ix.netcom.com HTTP://wlfraed.home.netcom.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list >
|
Pages: 1 Prev: GET PAID FOR WORKING ONLINE $100 ON YOUR FIRST DAY Next: How to swallow traceback message |