我正在寻找一个简单的解决方案来深度复制Yii模型,包括所有关系(更新外国id和东西),但到目前为止找不到令人满意的东西。
所以我提出了一个解决方案,并希望与您讨论。
我扩展了CActiveRecord并添加了此复制方法。你觉得怎么样?
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()