0
我試圖將多個Sharepoint站點的數據保存到SQLite數據庫文件中。我可以使用Sharepoint庫訪問數據。但無法將Sharepoint列表轉換爲Pandas Dataframe &,然後寫入SQLite表。 我用下面的網站的支持,這裏是我的代碼 https://pypi.python.org/pypi/sharepoint/0.4.1 Saving SharePoint list with Python將Sharepoint數據保存到SQLite表中
一個片段,我不知道是否存在通過SharePoint列表不同的技術來循環並寫入到SQL插入。我只是對熊貓圖書館更舒服一點。當前的計劃是Sharepoint LIst - > DataFrame - > SQL。我怎麼解決這個問題? PS:我是新來的Python和使用它僅上週:)
import pandas as pd
# Importing Sharepoint Library
from sharepoint import SharePointSite, basic_auth_opener
import urllib2
from ntlm import HTTPNtlmAuthHandler
# Windows Credentials
username="xxxxx"
password='xxxxxx'
# The sharepoint info
server_url="https://example.com/"
site_url=server_url+"sites/XYZ/"
# list_name='list_name'
# FieldName='Output Field'
passman=urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None,server_url,username,password)
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)
# Create and Install the opener
opener=urllib2.build_opener(auth_NTLM)
urllib2.install_opener(opener)
# Create a sharepoint object
site=SharePointSite(site_url,opener)
sp_list=site.lists['list_name']
# print row.id,row.Column1, row.Column2
TestDictionary=dict({'Column1':'Column1','Column2_x0020_Field2' : 'Column2'})
df=pd.from_dict(TestDictionary)
df.to_sql()