我正在尝试制作简单的网页,该网页将从 SQLite 文件中读取数据并将其显示在网页中,这非常简单,我想做 3 个 SQL 查询并显示结果。
我有使用Brython的想法,因为制作 Django/Flask 应用程序看起来更容易,
这是我的代码:
<html>
<head>
<script src="/brython.js"></script>
</head>
<body onload="brython('debug_mode')"> <!-- for debug --!>
<script type="text/python">
from browser import document, alert
from browser import html
def echo(ev):
alert(document["zone"].value)
document['mybutton'].bind('click',echo)
document['text'] <= html.P("testing")
document['text'] <= html.P("testing 222")
# get holidays for today
import sqlite3
import sys
sqlite3_connection = sqlite3.connect('test.db')
with sqlite3_connection:
sqlite3_cursor = sqlite3_connection.cursor()
sqlite3_cursor.execute('SELECT SQLITE_VERSION()')
data = sqlite3_cursor.fetchone()
document['text'] <= html.P("SQLite version: %s" % data)
</script>
<input id="zone"><button id="mybutton">click !</button>
<div id="text">
</div>
</body>
</html>
这不起作用,问题是 Brython 默认没有 sqlite3 实现。
有没有一些简单的方法可以将 sqlite3 添加到 Brython ?
我已经看到有一些谷歌夏天的代码项目,但在任何地方都没有找到结果。