Python sqlite3在本地成功,但在Github Action上失败

Kev*_*Tan 5 python sqlite github-actions

相同的 python 版本,相同的 sqlite3 版本和相同的文件,但我只是无法传递 Github Action。

\n

这是我的 github 操作:\n https://github.com/CloudAurora/Blog/blob/master/.github/workflows/main.yml

\n

和我的Python文件:https://github.com/CloudAurora/Blog/blob/master/scripts/init_database.py

\n

我可以在本地 Linux 机器上成功运行这个文件:

\n
Projects/Blog - [master\xe2\x97\x8f] \xc2\xbb python scripts/init_database.py -r ./posts --token  xxx\nsqlite version 2.6.0\nINSERT_USER_STATEMENT \n    INSERT INTO User(bio, email, githubId, name)\n    VALUES(?,?,?,?)\n    ON CONFLICT(name) DO NOTHING\n\nINSERT_USER_STATEMENT \n    INSERT INTO User(bio, email, githubId, name)\n    VALUES(?,?,?,?)\n    ON CONFLICT(name) DO NOTHING\n\nCreate db file in: ./prisma/dev.db, and env is set\n
Run Code Online (Sandbox Code Playgroud)\n

但是,当我将其推送到 github 时,它会在 Github Action 中失败:

\n
 sqlite version 2.6.0\nINSERT_USER_STATEMENT \n    INSERT INTO User(bio, email, githubId, name)\n    VALUES(?,?,?,?)\n    ON CONFLICT(name) DO NOTHING\n\nTraceback (most recent call last):\n  File "scripts/init_database.py", line 110, in <module>\n    c.execute(INSERT_USER_STATEMENT, author_info)\nsqlite3.OperationalError: near "ON": syntax error\n##[error]Process completed with exit code 1.\n
Run Code Online (Sandbox Code Playgroud)\n

您可以找到完整的日志:https://github.com/CloudAurora/Blog/runs/899163805 ?check_suite_focus=true

\n

mca*_*ans 7

为我解决类似的 SQLite 问题的是在我的 YAML 工作流程中,替换

runs-on: ubuntu-latest 
Run Code Online (Sandbox Code Playgroud)

runs-on: ubuntu-20.04
Run Code Online (Sandbox Code Playgroud)

ubuntu-latest 使用 Ubuntu 18.04,SQLite 版本似乎很旧并且有问题。