开发者

DB not persisting after end of program

I've created a simple DB using SQLAlchemy. After I connect to it via the engine, define the tables a开发者_JAVA百科nd classes, then create a User, it outputs the user fine. When the program ends and I try accessing the DB via the Python prompt (importing SQLAlchemy, creating a new engine, etc.) the previous users are gone.

Can someone explain what is happening here, and what (if anything) is in the previously set-up .db file?


Are you calling .commit() on the connection before releasing it?

By default the Python SQLite module does not use AUTOCOMMIT mode and, unless you finish your session with a DDL statement, it will be rolled back.

For more info: http://docs.python.org/library/sqlite3.html#controlling-transactions.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜