1

我正在尝试连接到我的(pysqlcipher)加密的 sqlite 数据库,但我失败了,因为 PRAGMA 密钥输入不正确。我在单独的 .env 文件中有正确的密码“test”。

即使一切都应该正确,我收到以下错误消息:连接到 sqlite 时出错。提供的绑定数量不正确。当前语句使用 0,并且提供了 1。

我该如何解决这个问题?我认为这是语法错误。

.env 文件

DATABASE_SECRET_KEY = test

蟒蛇脚本

import sqlite3
import os
from flask import Flask, render_template, jsonify, request, flash, redirect, url_for, session
from pysqlcipher3 import dbapi2 as sqlite3

sqliteConnection = sqlite3.connect('./database/test.db')
cursor = sqliteConnection.cursor()

PRAGMA_key = os.environ.get("DATABASE_SECRET_KEY")
cursor.execute("PRAGMA key = \'%s\';", [PRAGMA_key])

print("Successfully Connected to SQLite")

错误

Error while connecting to sqlite.

Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied.
4

0 回答 0