2
我正在重新創建以相當難以訪問的格式存儲的數據。大部分數據已成功移動並轉換。此Python腳本旨在根據舊數據庫標識每個對象的父級,並在新數據庫中更新它的父級(當前爲空)。pyodbc中的字符串參數
我:
# skip the Alpha
for x in range(2, i+1):
on_level = 'ORG_LEVEL' + str(x)
parent_level = 'ORG_LEVEL' + str(x-1)
cur.execute('''SELECT ?, ?
FROM OsuOrgs
WHERE ORG_LEVEL= ? ''',
[ on_level, parent_level, x ])
for row in cur.fetchall():
members.append({ "unv_id":str(row[0]), "parent":str(row[1]) })
for member in members:
print(member)
我遇到的問題是,我的會員[]對象充滿on_level和parent_level的litteral值。我的假設是,這與pyodbc如何傳遞參數有關,但我爲什麼會發生這種情況,我有點難過。
例子:
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
{'parent': 'ORG_LEVEL7', 'unv_id': 'ORG_LEVEL8'}
修復該問題。自從我發現後,我刪除了評論。對於那個很抱歉。 – Jacobm001