Revised: [DB-SIG] MySQLdb +cgi

Jackson david.jay.jackson@wcox.com
Tue, 30 Oct 2001 12:22:38 -0700


Ok --
Here's the corrected script. The host variable prints out fine,
but it's still no updating db (Yep, I verified the username and password") What about the construction of the exicute statement?
Do we need placeholders(?) or (%s)?

Thanks,
David

--------------------------- Script ---------------
#!/usr/bin/python
import cgi, MySQLdb
print "Content-Type: text/html\n"

form = cgi.FieldStorage()
if form.has_key("node"):
	host=form["node"].value
	print "<p>"
	print "Hostname: ",host
	print "</p>"
	db =SQLdb.connect("localhost","rca","rca1234","sirinfo")
	rca = db.cursor()
	rca.execute(""" insert into test(node)values(?)""",host)	
	
else:
	print "<h1>Dis doesn't look right</h1>"