循環讀取 Plist 字典寫入 SQLite,發現目標表比源數據少十幾行。
INSERT OR IGNORE 或報錯未處理)。FMDB 或原生 sqlite3_bind_* 參數化綁定,避免拼接 SQL。BEGIN TRANSACTION,結束 COMMIT,保證原子性。sqlite3_errcode()、sqlite3_errmsg() 定位失敗行。不建議在 App 端直接解析 Excel(libxlsxwriter 體積大、解析慢)。推薦流程:
pandas/openpyxl)或 Node.js 讀取 Excel,生成 SQLite 數據庫文件(.db)。.db 放入 App Bundle(Bundle Resources)。Documents 目錄供讀寫。import pandas as pd, sqlite3
df = pd.read_excel('data.xlsx')
conn = sqlite3.connect('data.db')
df.to_sql('table_name', conn, if_exists='replace', index=False)
conn.close()