Some More MySQL
Victor Subervi
victorsubervi at gmail.com
Thu May 27 14:16:10 EDT 2010
Hi;
But what about this?
sql = "select pic%d from %s where ID='%%s';" % (pic, store)
cursor.execute(sql % id)
If I try and rewrite the last line like this:
cursor.execute(sql, id)
it doesn't work. What do?
How about this one:
cursor.execute("insert into categories (Store, Category, Parent)
values('%s', '%s', Null)", (store, cat))
For some reason it puts single quotes around my variables! This doesn't
happen if I change that comma for a percent sign! What do?
How about this one:
sql = 'select * from options%s where ID=%%s', (opTable[0].upper() +
opTable[1:])
# cursor.execute(sql, id)
cursor.execute('select * from options%s where ID=%s' %
(opTable[0].upper() + opTable[1:], id))
The last one works, but if I comment it out and uncomment the middle line,
it doesn't. Same here:
sql = "update options%s set PriceDiff='%%s' where Field='%%s' and
ID=%%s and Store='%%s'" % (opTable[0].upper() + opTable[1:])
# cursor.execute(sql, (value, opName, id, store))
cursor.execute('update options%s set PriceDiff="%s" where Field="%s"
and ID=%s and Store="%s"' % (opTable[0].upper() + opTable[1:], value,
opName, id, store))
Please help.
TIA,
beno
TIA,
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100527/b4611a70/attachment.html>
More information about the Python-list
mailing list