你好,我正在尝试这样做,输入一个值从html和采取一个值从数据库和结果显示在一个html表,但我没有得到他们,我会显示我的代码
Python
@app.route('/search', methods=['GET', 'POST'])
def search():
if request.method == 'POST':
try:
sea = request.form['sea']
with sql.connect("DRIVER={SQL Server}; SERVER=AUS_COMPUTO02\SQLEXPRESS; DATABASE=WEBSERVICE; Trusted_Connection = yes;") as con:
cur = con.cursor()
cur.execute("SELECT *FROM PROVEEDOR WHERE ID_PROVEEDOR = (?)", (sea).format(sea))
sea=[dict(ID_PROVEEDOR=row[0], DECRIPCION=row[1]) for row in cur.fetchall()]
cur.commit()
msg = "Successfully added"
print(sea)
except Exception as e:
exit('error',e)
html格式
<form class="form-inline my-2 my-lg-0" action="{{ url_for('search') }}" class="form-control">
<input id="dt" name='sea' class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" >Search</button>
</form>
<table class="table" action="{{ url_for('search') }}">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">ID</th>
<th scope="col">Descipcion</th>
</tr>
</thead>
<tbody>
{% for s in slc %}
<tr>
<th scope="row">1</th>
<td>{{ s.ID_PROVEEDOR }}</td>
<td>{{ s.DECRIPCION }}</td>
</tr>
<tr>
{% endfor %}
</tbody>
如果有人感兴趣,我会把这个解决方案留在这里
相关问题 更多 >
编程相关推荐