[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
El dom, 06-06-2010 a las 20:34 +0100, Grant Sewell escribiÃ: > Hi all, > > I'm trying to add some data into a MySQL database using Python 2.6.5. > I'm using the following: > cursor.execute( 'INSERT INTO table (fielda, fieldb) VALUES ("%s","%s")' ) % > (variable_a, variable_b) > but, alas, what ends up in the table is "%s" and not the contents of the > variables. :( > > Any suggestions on what's the problem? I guess it's because the brackets are wrong, try this: cursor.execute( 'INSERT INTO table (fielda, fieldb) VALUES ("%s","%s")' % (variable_a, variable_b) ) Regards, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/ -- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html