Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read python pickle with scala

I inherited a database with values stored as Python pickled objects. Is there a way to unpickle these values in Scala (without calling Python internally) ?

like image 587
JulienD Avatar asked Oct 19 '22 11:10

JulienD


1 Answers

In general, you'd need to call python internally, because pickle allows classes to run arbitrary code on unpickling. (Do a search for "python pickle security" and you'll find a lot of interesting discussions about why this means you shouldn't unpickle from untrusted sources.)

I suspect it could be done for more common cases, though, if there's nothing particularly unusual in your pickled data. This simliar question has an answer suggesting a Java library called Pyrolite.

like image 129
Chris Martin Avatar answered Oct 21 '22 06:10

Chris Martin