0
import webapp2
import mysql.connector
class MainHandler(webapp2.RequestHandler):
def get(self):
db=mysql.connector.connect(host="localhost",user="root",password="bsit",database="registration")
mycursor=db.cursor()
mycursor.execute("select * from student")
result=mycursor.fetchall()
self.response.write(str(result))
app = webapp2.WSGIApplication([('/', MainHandler)], debug=True)
內部服務器錯誤 服務器已要麼犯錯或不能夠執行所請求的操作的。服務器內部錯誤在谷歌應用程序引擎使用python
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 1102, in __call__
return handler.dispatch()
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "C:\Users\Aaqib Nadeem\Desktop\db-test\main.py", line 6, in get
db=mysql.connector.connect(host="localhost",user="root",password="bsit",database="registration")
File "C:\Python27\lib\mysql\connector\__init__.py", line 162, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Python27\lib\mysql\connector\connection.py", line 129, in __init__
self.connect(**kwargs)
File "C:\Python27\lib\mysql\connector\connection.py", line 454, in connect
self._open_connection()
File "C:\Python27\lib\mysql\connector\connection.py", line 418, in _open_connection
self._do_handshake()
File "C:\Python27\lib\mysql\connector\connection.py", line 141, in _do_handshake
packet = self._socket.recv()
File "C:\Python27\lib\mysql\connector\network.py", line 255, in recv_plain
errno=2055, values=(self.get_address(), _strioerror(err)))
OperationalError: 2055: Lost connection to MySQL server at 'localhost:3306', system error:
請提供此錯誤
數據庫位於何處?您正嘗試在本地主機上訪問它。 mysql是否被部署爲谷歌應用程序引擎應用程序的一部分?我不認爲這是可能的。 –