The Artima Developer Community
Sponsored Link

Python Buzz Forum
Packing the ZODB offline

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Carlos de la Guardia

Posts: 219
Nickname: cguardia
Registered: Jan, 2006

Carlos de la Guardia is an independent web developer in Mexico
Packing the ZODB offline Posted: Jan 1, 2008 11:02 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Carlos de la Guardia.
Original Post: Packing the ZODB offline
Feed Title: I blog therefore I am
Feed URL: http://blog.delaguardia.com.mx/feed.atom
Feed Description: A space to put my thoughts into writing.
Latest Python Buzz Posts
Latest Python Buzz Posts by Carlos de la Guardia
Latest Posts From I blog therefore I am

Advertisement

While working for a client, I had the need to transfer the Data.fs file from the customer's server to my development machine, but I was not authorized to pack the database.

Due to other commitments I was working at night, so I would have to miss a whole day of work on this project if I waited for someone else to pack the db the next day. The file's size was 14GB so transfering it as it was really was out of the question.

I had a regular user ssh acount, so there were a couple of ways available for me to pack a copy of the ZODB, but the Python interpreter seemed to me to be the easiest path to success:

>>> import time
>>> import ZODB.FileStorage
>>> import ZODB.serialize
>>> storage=ZODB.FileStorage.FileStorage('/home/cguardia/Data.fs.copy')
>>> storage.pack(time.time(),ZODB.serialize.referencesf)

Done! The file shrunk from 14GB to 360MB and the transfer was done in time for me to get some work done that night.

In case anyone wonders about this, the referencesf parameter is part of the storage interface and is required for the pack method, even though apparently FileStorage doesn't use it in any way. If you are curious, referencesf is a function that returns the ids of objets inside a pickle. If you want to know still more, then you've got me. This is as far as I'm willing to go.


Read: Packing the ZODB offline

Topic: Bitter at all? Previous Topic   Next Topic Topic: Perlbal notes

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use