-1

クリップ:

[root@localhost 0]# python test13.wsgi
(1, 'aaaaaa')
[root@localhost 0]# 

アパッチ:

内部サーバーエラー

完全なスクリプト コード:

import MySQLdb
conn = MySQLdb.connect (host = "localhost",
                        user = "root",
                        passwd = "",
                        db = "aaa")
cursor = conn.cursor ()
cursor.execute ("select * from bbb limit 1")
row = cursor.fetchone ()
print row
cursor.close ()
conn.close ()

def application(environ, start_response):
    start_response('200 OK', [('content-type', 'text/html')])
    return row

エラーログ:

[Fri May 10 16:04:07 2013] [info] mod_wsgi (pid=3692): Attach interpreter ''.
[Fri May 10 16:04:20 2013] [info] mod_wsgi (pid=3691): Create interpreter 'localhost.localdomain|/0'.
[Fri May 10 16:04:20 2013] [info] [client 127.0.0.1] mod_wsgi (pid=3691, process='', application='localhost.localdomain|/0'): Loading WSGI script '/0/test13.wsgi'.
[Fri May 10 16:04:20 2013] [error] (1, 'aaaaaa')
[Fri May 10 16:04:20 2013] [error] [client 127.0.0.1] mod_wsgi (pid=3691): Exception occurred processing WSGI script '/0/test13.wsgi'.
[Fri May 10 16:04:20 2013] [error] [client 127.0.0.1] TypeError: sequence of byte string values expected, value of type int found
4

1 に答える 1

0

application文字列の iterable を返す必要があります。Yours は、整数と文字列のタプル (反復可能) を返しますが、これは機能しません:

TypeError: sequence of byte string values expected, value of type int found

returnその行を次のように変更します。

return [repr(row)]
于 2013-05-10T23:17:20.257 に答える