【问题标题】:Remote .db file doesn't change远程 .db 文件不会改变
【发布时间】:2015-12-25 12:48:49
【问题描述】:

我正在使用 cyclone 在 OpenShift 上开发应用程序。

该应用程序使用 sqlite3 连接到 .db 文件并对其进行更改。

script_dir = os.path.dirname(__file__)
rel_path = "database/main.db"
database = sqlite3.connect(os.path.join(script_dir, rel_path), timeout=1)
database.row_factory = sqlite3.Row
db = database.cursor()

def closegame(id):
    db.execute("UPDATE games SET Running = 'No' WHERE ID = ?", (id,))
    database.commit()
  • 当我下载文件时

    rhc scp appname download mylocation remotelocation
    

    没有变化。

  • 当我尝试 git fetch/merge/pull 时,它已经是最新的了。

  • 当我重新启动应用程序时,结果是一样的,并且 应用程序仍在使用 .db 的更新版本

  • 当我 git push 时,文件被我的本地文件覆盖

  • 将 path/database/main.db 添加到 .gitignore 仍然会覆盖文件

  • git rm --cached 从远程完全删除文件,因此应用程序甚至不会启动

  • git update-index --assume-changed 无效

理想情况下,我希望文件永远不会被推送覆盖,而是能够通过拉取下载。如果那是不可能的,只要能拉出来就好了。

【问题讨论】:

    标签: python database git sqlite openshift


    【解决方案1】:

    问题是我对 git 缺乏了解。 Git 应该用于源文件,而不是实际数据。因此,我们应该在需要时通过 scp 下载数据库

    在 Openshift 中,可以在 app-root/repo/ 中找到工作的 .db 文件

    因此控制台中的最终命令是

    rhc scp appname download localpath app-root/repo/path/to/file
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多