I'm having difficulty loading a pickle in Python that was dumped in IronPython.
When I pickle something basic like "[1,2,3]" in IronPython, the pickle loads fine in Python. But, when I pickle results from the DB query below in IronPython, I get the error "No module named clr" when trying to load the pickle in Python.
What might be going wrong? (And is there a better way to share data between Python and IronPython?)
def GetData(id):
TheConnection = SqlClient.SqlConnection("server=MyServer;database=MyDB;Trusted_Connection=yes")
TheConnection.Open()
sqlcommand = "MyStoredProcedure#GetMyData '%s'" %id
MyAction = SqlClient.SqlCommand(sqlcommand, TheConnection)
MyReader = MyAction.ExecuteReader()
results = list()
while MyReader.Read():
row = {
'Type':'LolCat',
'Date':datetime.datetime(MyReader[1]),
'Location':str(MyReader[3]),
'Weight':float(MyReader[6])/float(MyReader[7]),
}
results.append(row)
TheConnection.Close()
MyReader.Close()
return results
results1 = GetData(1234)
results2 = GetData(2345)
...
picklefile= open("testpickle","w")
cPickle.dump((results1,results2),picklefile)
...
picklefile = open("testpickle","r")
p = cPickle.load(file) # this is the line that gives the error "ImportError: No module named clr"
clr
installed and your Cpython install doesn't have it. – Maxfield