python - 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.
解决方案
如果您的 sqlite db 有一些 pre 表和记录,则应将其上传到 vc 以供用户使用。但是如果您的项目的每个实例都需要一个干净的数据库,我建议您在应用程序的初始化过程中创建数据库。
此外,如果您的应用程序需要数据库中的一些预数据,最佳实践之一是将数据放入文件中,如predata.json
在初始化期间,创建数据库并将其导入数据库。
推荐阅读
- javascript - React 有条件地设置导航
- c# - 如何在 Ubuntu 上运行依赖于 NuGet 包的 .net Core 应用程序
- facebook - 无法使用 Facebook 图形 API 创建广告创意
- php - 在 localhost 中打开 10 月 cms
- xml - SAPUI5 搜索字段建议自动完成
- python - 从日期python中提取年/月到新列
- wordpress - woocommerce 产品导入在后端不起作用
- c# - 使用字符串计算除法
- linux - Linux 中的输出格式
- python - Keras 自定义损失:a * MAE + (1-a) * 常量