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

标签 python sqlite github-actions

相同的 python 版本,相同的 sqlite3 版本,相同的文件,但我就是无法通过 Github Action。

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

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

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

Projects/Blog - [master●] » python scripts/init_database.py -r ./posts --token  xxx
sqlite version 2.6.0
INSERT_USER_STATEMENT 
    INSERT INTO User(bio, email, githubId, name)
    VALUES(?,?,?,?)
    ON CONFLICT(name) DO NOTHING

INSERT_USER_STATEMENT 
    INSERT INTO User(bio, email, githubId, name)
    VALUES(?,?,?,?)
    ON CONFLICT(name) DO NOTHING

Create db file in: ./prisma/dev.db, and env is set

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

 sqlite version 2.6.0
INSERT_USER_STATEMENT 
    INSERT INTO User(bio, email, githubId, name)
    VALUES(?,?,?,?)
    ON CONFLICT(name) DO NOTHING

Traceback (most recent call last):
  File "scripts/init_database.py", line 110, in <module>
    c.execute(INSERT_USER_STATEMENT, author_info)
sqlite3.OperationalError: near "ON": syntax error
##[error]Process completed with exit code 1.

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

最佳答案

在我的 YAML 工作流中为我解决了一个类似的 SQLite 问题,替换

runs-on: ubuntu-latest 

runs-on: ubuntu-20.04

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

关于Python sqlite3 在本地成功,但在 Github Action 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63034846/

相关文章:

python - 在 python basemap 上绘制点会产生运行时错误

python - Pylons Paster 不重新加载代码

java - 如何在 SQLite 数据库中存储 DatePicker 时间?我的老是崩溃

android - 检查数据库值

docker - Github Actions,自托管运行器 : Possible to add options to 'docker create' ?

python - 在Python中找出具有一定长度的列表的数量

python - 为什么 "isinstance(numpy.float64,numbers.Real)"返回 False?

sqlite - 如何从 db [HTML5] 中获取两个相同的字段数据?

Github Action /缓存@v2 : unrecognized option: posix in the post job

macos ${{ env.TMPDIR }} 在 github 操作中不起作用