Package sage :: Package tables :: Module db :: Class Database
[show private | hide private]
[frames | no frames]

Type Database

object --+    
         |    
     _uniq --+
             |
            Database

Known Subclasses:
Database, Database, Database

Method Summary
  __init__(self, name, read_only, thresh)
  __getitem__(self, x)
  __repr__(self)
  __setitem__(self, x, y)
  abort(self)
  as_dict(self, keys)
Return a dict representation of the database.
  changed(self, key)
Informs the database that some items corresponding to the given key may have changed.
  clone(self, new_name)
Copy the database to a new database with the given new_name.
  commit(self)
Commit the new version of this object to the database file.
  delete_all(self)
Delete every entry in the database.
  dump_as_dict(self, filename, keys)
  dump_as_dict_intervals(self, basename, Nstart, Nstop, length)
  has_key(self, x)
  keys(self)
  pack(self)
This should pack, but I couldn't get pack working with compressed storage.
  rebuild(self, thresh)
Completely rebuild the database from scratch, by going through and writing everything out to a temporary database, then moving the temporary database files over self's files.
  restore_from_dict(self, filename)
Restore from the filename which must store a pickled dict.
  restore_from_dict_all(self, basename)
Restore all files that start with the given basename.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Instance Method Details

as_dict(self, keys=None)

Return a dict representation of the database.

Since the database could be large, if the optional keys parameter is given then only the elements of the database with key in keys are listed.

changed(self, key)

Informs the database that some items corresponding to the given key may have changed. This does not commit the changes to disk (use the commit function after calling changed to do that).

clone(self, new_name)

Copy the database to a new database with the given new_name. There must not be a database with the new_name already, or a RuntimeError exception is raised.

commit(self)

Commit the new version of this object to the database file.

Note that if a data item corresponding to a key is changed, you still have to tell the database that that data item was changed by calling the changed method with that key.

delete_all(self)

Delete every entry in the database.

pack(self)

This should pack, but I couldn't get pack working with compressed storage. You can use the rebuild function instead, though it's slower than the usual pack.

rebuild(self, thresh=None)

Completely rebuild the database from scratch, by going through and writing everything out to a temporary database, then moving the temporary database files over self's files. This can take a long time.

The main reason for this function is that unfortunately I can't get pack to work on compressed ZODB databases.

A copy of the old database file is created before rebuild.

If you specify a thresh then that threshhold is used for recompressing all the objects. Note that the threshhold is not saved as part of the database, so new objects will be compressed using whatever threshhold you use when creating the database object.

restore_from_dict(self, filename)

Restore from the filename which must store a pickled dict.

After loading the database is committed.

restore_from_dict_all(self, basename)

Restore all files that start with the given basename.

Each file is loaded then commited to disk before the next file is loaded.

Generated by Epydoc 2.1 on Fri Jun 24 17:58:45 2005 http://epydoc.sf.net