我跟着這個鏈接: 「https://pypi.python.org/pypi/bottle-mysql/0.1.1」我試圖用bottle.py連接MySQL,但它顯示的錯誤
和 「http://bottlepy.org/docs/dev/」
這是我的PY文件:
import bottle
from bottle import route, run, template
import bottle_mysql
app = bottle.Bottle()
# # dbhost is optional, default is localhost
plugin = bottle_mysql.Plugin(dbuser='root', dbpass='root', dbname='delhipoc')
app.install(plugin)
@route('/hai/<name>')
def show(name,dbname):
dbname.execute('SELECT id from poc_people where name="%s"', (name))
print "i am in show"
return template('<b>Hello {{name}}</b>!',name=name)
run(host='localhost', port=8080)
這是我的代碼,它拋出錯誤,如:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\bottle.py", line 764, i
return route.call(**args)
File "C:\Python27\lib\site-packages\bottle.py", line 1575,
rv = callback(*a, **ka)
TypeError: show() takes exactly 2 arguments (1 given)
請幫我
我和一個手工製作的插件一樣痛苦。這裏的問題是設置插件時,回調顯示爲沒有參數:( 我仍然無法使它工作... – Fabzter