我有这样的功能
def main():
''' Demonstrate UDF '''
with sqlite3.connect("User.db") as conn:
conn.row_factory = dict_factory
conn.create_function("date_parse", 1, date_parse)
cur = conn.cursor()
rows = cur.execute("SELECT Status,date_parse(DateEntered) as 'DateEntered', EnteredBy, DateModified, AccountName,SalesRepName FROM data WHERE Status!=''and EnteredBy!='' order by DateEntered asc ").fetchall()
def date_parse(s):
''' Converts a string to a date '''
try:
t = parser.parse(s, parser.parserinfo(dayfirst=True))
return t.strftime('%Y/%m/%d %H:%M')
except:
return None
def dict_factory(cursor, row):
''' Helper for dict row results '''
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
当我使用
for row in rows:
print (row)
我得到了我需要的所有数据,以适当的方式订购,当我想在我的网络应用程序上显示它时,我得到了例外
@app.route('/Accont/')
def SetUp():
# ...code
return render_template('navbar.html',rows = rows)
我试图在没有请求的情况下直接从jinga2呈现模板,但这对我没有帮助。有人能帮我在我的网络应用程序上按正确的顺序显示这些数据吗?你知道吗
你知道吗导航栏.html你知道吗
<thead>
<tr>
<th>Status</th>
<th>DateEntered</th>
<th>EnteredBy</th>
<th>DateModified</th>
<th>AccountName</th>
<th>SalesRepName</th>
</thead>
<tbody>
{% for row in rows %}
<td>{{row[0]}}</td>
<td>{{row[1]}}</td>
<td>{{row[2]}}</td>
<td>{{row[3]}}</td>
<td>{{row[4]}}</td>
<td>{{row[5]}}</td>
{%endfor%}
获取此错误:sqlite3.OperationalError:用户定义函数引发异常
目前没有回答
相关问题 更多 >
编程相关推荐