On Thu, 2010-05-27 at 09:34 -0400, Victor Subervi wrote: > On Thu, May 27, 2010 at 8:34 AM, Victor Subervi > <victorsube...@gmail.com> wrote: > Hi; > I have this code: > > sql = "insert into %s (%s) values ('%%s');" % > (personalDataTable, string.join(cols[1:], ', ')) > # cursor.execute(sql, string.join(vals[1:], "', '")) > cursor.execute('insert into %s (%s) values ("%s");' % > (personalDataTable, string.join(cols[1:], ', '), > string.join(vals[1:], '", "'))) > > Now, if I uncomment the 2nd line and comment the third, the > command fails because, apparently, that "');" at the tail end > of sql (1st line) gets chopped off. Why?? > > (Note to self: enterPeople3.py) > > ...and here's another one: > > print 'insert into categories (Store, Category, Parent) > values("%s", "%s", Null)'% (store, cat) > # cursor.execute('insert into categories (Store, Category, > Parent) values("%s", "%s", Null)', (store, cat)) >
Lose the quotes around the %s. I'm pretty sure somebody mentioned this in the previous MySQL problem thread. -- regards, kushal -- http://mail.python.org/mailman/listinfo/python-list