0
データベースのsqlite3の: Pythonの私は以下の私のコードで小さなプログラムを持っ
def get_code(hex_pattern, database='./AndroidLockScreenRainbow.sqlite'):
try:
if os.path.exists(database):
with lite.connect(database) as db:
with db.cursor() as c:
c.execute("SELECT * FROM RainbowTable")
rows = c.fetchall()
for row in rows:
if row[0] == hex_pattern:
return row[1]
else:
raise lite.OperationalError("Database file not exists")
except lite.OperationalError:
print('Given SQL table not found!')
コードは、プログラムは次のエラー
になります:、Cなど)db.cursor(とラインに到達with db.cursor() as c: AttributeError: __exit__
どうしますか?
カーソルはコンテキストマネージャをサポートしていません。あなたはそれで 'with'を使うことはできません。 –