0
文件models.py瓶卡桑德拉查詢LIKE
class Document(db.Model):
__table_name__ = 'document'
nim = db.columns.Integer(primary_key=True)
prodi = db.columns.Text(primary_key=True)
tahun = db.columns.Date(primary_key=True, clustering_order="DESC")
title = db.columns.Text(primary_key=True)
nama_mhs = db.columns.Text()
angkatan = db.columns.Date()
intisari = db.columns.Text()
kata_kunci = db.columns.Text()
pembimbing = db.columns.Text()
file_doc = db.columns.Text()
password = db.columns.Text()
def __repr__(self):
return '<Document %r>' % (self.nim, self.nama_mhs, self.angkatan, self.tahun, self.prodi, self.judul, self.kata_kunci, self.intisari, self.pembimbing, self.password, self.file_doc)
這是我創建的搜索表單,search.html
<from action="{{ url_for('search') }}" method="POST">
<input name="search" type="text" class="form-control" placeholder="Search">
<button type="submit">
</from>
如何進入隨機文本?文件views.py方法搜索()
@app.route('/search', methods=['GET','POST'])
def search()
q1 = sesi.execute(" SELECT title FROM document WHERE title LIKE '%request.form['search']%' ")
return render_template("title_search.html", q1=q1)
title_search.html
{% extends "base.html" %}
{% block content %}
{% include "search_document.html" %}
<hr>
{% for data in q1 %}
<div class="col-md-8">
<h3>Title : <a href="#"> {{ data.title }} </a></h3>
<hr>
</div>
{% endfor %}
{% endblock %}
我得到這個在運行
SyntaxException:錯誤從服務器:代碼= 2000 [語法的CQL錯誤 query] message =「line 1:61 missing'EOF at'search'(... document WHERE title LIKE'%request.from ['[search]'] ...)」
並未奏效尚未 –
能否請您發佈完整的跟蹤日誌? –
我試圖添加一個跟蹤到我的問題,我希望你能理解結構 –