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

2024-09-30 18:31:38 发布

您现在位置:Python中文网/ 问答频道 /正文

相同的python版本、相同的sqlite3版本和相同的文件,但我无法传递Github操作

以下是我的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操作中失败:

 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


Tags: 文件namehttpsgithubmastercominiton
1条回答
网友
1楼 · 发布于 2024-09-30 18:31:38

对我来说,修复类似SQLite问题的是我的YAML工作流,替换了

runs-on: ubuntu-latest 

runs-on: ubuntu-20.04

ubuntu最新版本使用的是Ubuntu18.04,而SQLite版本似乎很旧,存在问题

相关问题 更多 >