0
我使用pypyodbc從ms sql服務器讀取數據。PyPyOdbc正確使用遊標
我不確定遊標是否應該在任何查詢後關閉,或者只是在最後一次,我在文檔中找不到任何東西。
例子:
curs = con.cursor()
for id in id_list:
curs.execute ('Select * from XXX where id = {}'.format (id))
curs.fetchall()
# Write the data into the target...
# curs.close() ???
curs.close()
這是正確的嗎?
感謝
什麼關閉遊標當你用它做。 –
如果它爲遊標實現了標準PEP(https://www.python.org/dev/peps/pep-0249/),則相關:https://stackoverflow.com/questions/5669878/when-to-close -cursors-使用-MySQLdb的 –