[問題] cgi上面 import MySQLdb 無法成功,但是直接執行正常
我寫了下面這隻python程式要來獲得MySQL裡面的資料
#!/usr/bin/python
#coding:utf-8
import MySQLdb
conn = MySQLdb.connect(host="x.x.x.x",user="xx",passwd="xx",db="xx")
cursor = conn.cursor()
cursor.execute("select * from rule")
result = cursor.fetchall()
print "Content-Type: text/html" # HTML is following
print # blank line, end of headers
print "<html>"
print "<head>"
print "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"
print "<title> Python import MySQLdb</title>"
print "</head>"
print "<body>"
for record in result:
print record[0]
print "</body>"
如果我直接在 console 裡面 python sql.py的話可以正確獲得資料
但是放到網站上面想要作成cgi來用的時候就會出現
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, you@example.com and inform them of
the time the error occurred, and anything you might have done that may have
caused the error.
More information about this error may be available in the server error log
錯誤訊息蠻多的,我貼在這邊。
http://sites.google.com/site/iwhiori/home/python-mysqldb-error
總而言之我想要用 python 在網頁上面讀取資料庫資料
咕狗了超過八個小時!!還是找不到答案...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.174.37.8
→
07/04 20:27, , 1F
07/04 20:27, 1F
推
07/05 01:30, , 2F
07/05 01:30, 2F
→
07/05 01:36, , 3F
07/05 01:36, 3F
→
07/05 10:48, , 4F
07/05 10:48, 4F
Python 近期熱門文章
PTT數位生活區 即時熱門文章