python / sqlite3

编程入门 行业动态 更新时间:2024-10-22 19:41:56
python / sqlite3 - 编写文件的过程是什么?(python / sqlite3 - Which is the process writing the file?)

如果我在python中使用sqlite3构建数据库,那么编辑数据库文件的进程是什么?

我是否能够从shell注意到数据库未关闭 - 即使当前没有提交插入?

If I build a database using sqlite3 from within python, what will be the process called that edits the database file?

Will I be able to notice from shell that a database is not closed - even if no inserts are currently being committed?

最满意答案

SQLite是一个嵌入式数据库,因此没有单独的进程。

您可以使用lsof或类似工具检查Python进程是否具有数据库文件的打开句柄。 但是,这种手柄对应于开放连接; 它不会告诉您是否存在活动交易。

事务锁定DB文件; 您可以尝试使用lslk或lslocks 。 但是如果你真的想对数据库做一些事情,那么最好使用SQLite本身的同步机制,并尝试执行BEGIN EXCLUSIVE 。

SQLite is an embedded database, so there is no separate process.

You can check with lsof or similar tools whether the Python process has an open handle to the database file. 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. 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.

更多推荐

本文发布于:2023-07-04 16:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1026899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!