3

I am using python 3, and have heavy variables in memory, I would like to seamlessly allowing myself to write them to disk, and load them when I actually need them, without the need for pickling and reading from disk explicitly any time I need them. Is that at all possible and how?

I tried RDFlip but this does not seem to work It's a store that you need to explicitly approach, and I am trying to make it seamless.

thebeancounter
  • 3,893
  • 6
  • 49
  • 98

2 Answers2

1

You might want to look into something like an Object Relational Mapping (ORM) library that lets you store the objects to a database, and retrieve them by using Python method/function calls (rather than SQL statements). SQLAlchemy is one of the most popular ORMs for python, and has tons of documentation and community support available online. You would have to do the "explicit" work you are talking about only once, when defining your database tables and configuring DB connectivity, etc for SQLAlchemy, But then after that, you could just use a single method call to write your variables to disk (in the DB), and another for retrieving them. And unlike pickle, you can store any binary object in your database, so you aren't limited as far as what kind of data you can serialize/store.

J. Taylor
  • 4,060
  • 3
  • 28
  • 53
  • I need it to be any variable, and i need to store to be seamless, just telling python or some object that in this part of code, All the variables are on disk. something that is more similar to dask's on disk shuffle when it comes to dataframes. – thebeancounter Feb 10 '19 at 08:12
1

have you tried HDF5. I think this will be something what you are looking for. HDF5

JAbr
  • 207
  • 2
  • 10