![]() |
| ||
| python mysql doesnt work?plz help this is a program that i have, i dont know why it doesnt work. Could some one help me? thank you very much
i get an error at OperationalError. It says OperationalError is undefined. now if i take out OperationalError it wont work because of the line......%s" % message inside that try and catch function. Now if i take those two codes then i will get it to have the drop down list but there is nothing in that drop down list. This is the code i have #!c:\Python24\python.exe I'm using pythong to connect to mysql. here is my table structure for books database create table authors( authorID char(3), firstName varchar(20), lastName varchar(20) insert into authors values('1','Harvey','Deitel'); insert into authors values('2','Paul','Deitel'); insert into authors values('3','Temn','Nieto'); insert into authors values('4','Kate','Steinbuhler'); insert into authors values('5','Sean','Santry'); insert into authors values('6','Ted','Linn'); insert into authors values('7','Praveen','Sadhu'); insert into authors values('8','David','McPhie'); insert into authors values('9','Cheryl','Yaeger'); insert into authors values('10','Marina','Zlatkina'); insert into authors values('11','Ben','Wiedernann'); insert into authors values('12','Jonathan','Liperi'); pleaze help me. thank you very much. ); then in the end it should have a drop down list that contains id, fname, lname like this 1, Harvey, Deitel 2,..................... plz help me the error i got now from error log in apache is " File "C:/Programfiles/Apache2.2/cgi-bin/fig35_22.py", line 41\r [Thu Oct 19 22:24:18 2006] [error] [client 111.1.1.0] print """</body></html>"""\r [Thu Oct 19 22:24:18 2006] [error] [client 111.1.1.0] ^\r [Thu Oct 19 22:24:18 2006] [error] [client 111.1.1.0] SyntaxError: invalid syntax\r what is wrong with the code. When i open the page http://localhost/cgi-bin/filename.py i see the drop down list but inside is empty and no "Execute Querry" button . plz help me |
| ||
| Re: python mysql doesnt work?plz help I keep reading that MySQL is hard to program with, no matter what computer language you use. Hope you find someone familiar with MySQL. |
| ||
| Re: python mysql doesnt work?plz help > what is wrong with the code. Several things, actually. What is the stray quote doing in: font-family: Arial, sans-serif; font-size: 11pt"> ?But I suspect the real problem is here: print """<option value = %d>%s, %s</option>""" \You are treating author[ 0 ] like an integer (with the %d format) but your table definition lists it as a char(3), and you are (correctly) inserting string values. Ergo, a quick switch from %d to %s should solve the problem. I was able to get the form generated properly, including the "Execute Query" button. I have had only good experiences combining Python (2.4+) and MySQL (5.0+). SQL can be a pain sometimes but the MySQL.com newbie forum has always been helpful to me, for well-phrased questions. |
| All times are GMT -4. The time now is 2:54 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC