【发布时间】:2016-01-19 12:34:51
【问题描述】:
我正在尝试将 sqlite3 用于我的 python 项目。我需要制作一个注册页面来注册用户以访问其他功能。所以我需要检查用户名或电子邮件是否存在。我被禁止使用 ORM(对不起我的英语不好)。我通过的唯一教程是这个:http://flask.pocoo.org/docs/0.10/tutorial/introduction/ 但我不知道如何使用数据库,如何获取表格信息和单元格以及...... 你能告诉我怎么做或给我一个参考吗? 我想我必须知道一些这样的命令:
@app.route('/')
def show_entries():
#specially this line
cur = g.db.execute('select title, text from entries order by id desc')
entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]
return render_template('show_entries.html', entries=entries)
【问题讨论】:
-
看看教程中的source code。它应该有帮助!
-
我做了这个小应用程序,它运行良好。我只想使用我的 python 项目中的 sqlite3 数据库。
-
你需要了解一些SQL;知道如何使用 python 和 sqlite3(built-in module: sqlite3),如何使用 sqlite3 和 flask(Using SQLite 3 with Flask)。