我正在嘗試在 sqlite 資料庫中選擇表的特定列。我正在使用以下內容:
cursor = connection.execute('select Case from SUMMARY')
即使列名是正確的,每當我運行代碼時,我都會收到以下錯誤。
當我嘗試獲取列索引時也會發生同樣的情況。
每當我嘗試任何其他列時,我都可以獲取該列的所有資料。
OperationalError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_15288/2883478922.py in <module>
1 import sqlite3
2 connection = sqlite3.connect("../DB_Cases.sqlite")
----> 3 cursor = connection.execute('select Case from SUMMARY')
OperationalError: near "from": syntax error
uj5u.com熱心網友回復:
case是SQLite 中的保留關鍵字。
在 SQLite 檔案中提到的查詢中使用雙引號應該可以使您的查詢正常作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/415040.html
標籤:
