0
私の大学のプロジェクトとしてショップページを作成しています。私はデータベースをセットアップして、選択して使用して、選択した部分に関する情報を表示する新しいページを開くことを試みます。私はちょうどデータベースからデータを抽出することができないようです、あなたは助けてくださいできますか?私のhtmlの一部sqlとpythonを使った自己処理ページ
<p class="heading2">List of CPU's:</p>
<form action="show_part.py">
<select name="component">
<option value="Intel_i7-5960x">Intel i7-5960x</option>
が、これは、私はちょうど、コードは罰金である意味、新しいページにエラーメッセージが出続けるされて何が起こるのpython
#!/usr/local/bin/python3
from cgitb import enable
import pymysql as db
from cgi import FieldStorage
print('Content-Type: text/html')
print()
form_data = FieldStorage()
component = form_data.getfirst("name")
result=''
try:
connection = db.connect('***', '***', '***', '***')
cursor = connection.cursor(db.cursors.DictCursor)
result += cursor.execute("""SELECT price
FROM components
WHERE name = %s""" % (component))
cursor.close()
connection.close()
except db.Error:
result = '<p>Sorry! We are experiencing problems at the moment. Please call back later.</p>'
print("""
<!DOCTYPE html>
<html lang="en">
<head>
<title>Part details</title>
</head>
<body>
%s
</body>
</html>""" % (result))
あります
データベースクエリに関するもの。助言がありますか ?私は、問題は、プログラムを実行しようとしたSQLクエリ、にあった、私はそれを割れて考える