阅读flask文档遇到的问题及改写的其他问题

1、sessoin的问题

如果不写secret_key,无法使用session

app = Flask(__name__)
#在这之后加上secret_key,以随机数写入
app.secret_key=os.urandom(10)

2、g库模块看不懂 百度也找不太到资料

整个模块用sqlite3模块代替

import sqlite3

2.1、sqlite3库是用with 和fetchall

#很多教程和手册没有用with 和 fetchall
with sqlite3.connect(dbfile) as conn:
    c = conn.cursor()
    c.execute('select * from test')
    t=c.fetchall()
#t就是查询的元素了

2.2、处理没有表和primary key 重复

本来想用try来处理,可是,,,不知道expert

 

posted @ 2018-10-18 16:02  DoBgcYy  阅读(84)  评论(0编辑  收藏  举报