简体   繁体   English

python / sqlite3-写入文件的进程是哪个?

[英]python / sqlite3 - Which is the process writing the file?

If I build a database using sqlite3 from within python, what will be the process called that edits the database file? 如果我从python内部使用sqlite3构建数据库,那么将如何编辑数据库文件?

Will I be able to notice from shell that a database is not closed - even if no inserts are currently being committed? 我能否从Shell注意到数据库没有关闭-即使当前没有提交插入操作?

SQLite is an embedded database, so there is no separate process. SQLite是嵌入式数据库,因此没有单独的过程。

You can check with lsof or similar tools whether the Python process has an open handle to the database file. 您可以使用lsof或类似工具检查Python进程是否具有数据库文件的打开句柄。 However, such a handle corresponds to an open connection; 但是,这种手柄对应于打开的连接。 it does not tell you whether there is an active transaction. 它不会告诉您是否有活动的交易。

A transaction locks the DB file; 事务锁定数据库文件; you can try to check for that with lslk or lslocks . 您可以尝试使用lslklslocks进行检查。 But if you actually want to do something with the DB, it might be a better idea to use the synchronization mechanisms of SQLite itself, and to try to execute BEGIN EXCLUSIVE . 但是,如果您实际上想对数据库做一些事情,最好使用SQLite本身的同步机制并尝试执行BEGIN EXCLUSIVE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM