简体   繁体   English

SQLite数据库备份

[英]SQLite database backup

For backup of SQLite database, I went through https://www.sqlite.org/backup.html I came to know that there is one python wrapper over these SQLite online backup APIs.So, I went through https://github.com/husio/python-sqlite3-backup Here are some doubts that I have about sqlitebck(python package) 为了备份SQLite数据库,我经历了https://www.sqlite.org/backup.html,我知道这些SQLite在线备份API上有一个python包装器,因此,我经历了https:// github。 com / husio / python-sqlite3-backup这是我对sqlitebck(python软件包)有的疑问

  1. I checked out the code in tests, it shows db is copied from :memory: to file and vice versa using sqlitebck.copy(:memory:,dbfile), I am confused about ":memory:" and its use. 我在测试中签出了代码,它显示使用sqlitebck.copy(:memory:,dbfile)将db从:memory:复制到文件,反之亦然,我对“:memory:”及其使用感到困惑。
  2. Instead from memory, can I copy one database file to other database file like sqlitebck(dbfile1, dbfile2). 可以从内存中复制一个数据库文件到另一个数据库文件,例如sqlitebck(dbfile1,dbfile2)。 so that dbfile2 will be the backup of dbfile1? 这样dbfile2将成为dbfile1的备份?

':memory:' as a "filename" is how you tell sqlite to keep a small DB in memory rather than on-disk. ':memory:'作为“文件名”是您告诉sqlite如何在内存中而不是磁盘上保留一个小的DB。 But yes, sqlitebck is fine to copy from file to file -- though the arguments it takes are sqlite connections so you'd need to sqlite3.connect to each file first (and usually might as well just copy the file directly w/o involving sqlite -- as the sqlite page you link to implies, suggesting Unix cp or Windows copy ... Python has its own standard library module for file copies, https://docs.python.org/2/library/shutil.html ). 但是是的, sqlitebck可以从一个文件复制到sqlitebck文件-尽管需要使用的参数是sqlite 连接,所以您需要先sqlite3.connect到每个文件(通常也可以直接复制文件,而无需sqlite链接到的sqlite页面暗示,建议使用Unix cp或Windows copy ... Python有自己的文件复制标准库模块, https://docs.python.org/2/library/shutil.html ) 。

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

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