首页 > 解决方案 > Should an embedded SQLite DB used by CLI app be uploaded to version-control (Git)?

问题描述

I'm working on a Python CLI app that has to manage some data on a sqlite db (creating, updating and deleting records). I want the users to be able to install the app and use it right away. So my question is, can I just upload an empty sqlite db to GitHub? Or should I just upload a schema file and during installation build the db in a build step? I suppose if going the second way, users should have sqlite pre-installed or else the installation will fail. What I want is for them to just install the app, without worrying about dependencies and such.

标签: pythongitsqlitegithubpython-poetry

解决方案


如果您的 sqlite db 有一些 pre 表和记录,则应将其上传到 vc 以供用户使用。但是如果您的项目的每个实例都需要一个干净的数据库,我建议您在应用程序的初始化过程中创建数据库。

此外,如果您的应用程序需要数据库中的一些预数据,最佳实践之一是将数据放入文件中,如predata.json在初始化期间,创建数据库并将其导入数据库。


推荐阅读