开发者

flaskr- flask tutorial database confusion?

http://flask.pocoo.org/docs/tutorial/dbinit/- In this step of the Flask tutorial is written-

Such a schema can be created by piping the schema.sql file into the sqlite3 command as follows:

sqlite3 /tmp/flaskr.db < schema.sql

The downside of this is that it requires the sqlite3 command to be installed which is not necessarily the case on every system. Also one has to provide the path to the database there which leaves some place for errors. It’s a good idea to add a function that initializes the database for you to the applicati开发者_开发问答on.

Are both, piping the schema.sql file and adding a function, necessary or are they alternatives?


They're alternatives. I think the author suggests that when you're following the tutorial, piping the sql is okay, but when you're writing your own real applications, you should add a function and use that instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜