Search code examples
pythonpersistentzodb

Why Persistent class is not working for ZODB


Im new to the ZODB and Python in general. Im following tutorial from this page: http://www.zodb.org/en/latest/articles/ZODB1.html

On that page under "Persistent Classes" section there is a piece of code:

import ZODB
from Persistence import Persistent

For some reason it gives me error: "ModuleNotFoundError: No module named 'Persistence'"

What am i missing ? Creating and connecting to database works just fine.


Solution

  • That article is fairly old now and assumes ZODB version 1.x; look at http://www.zodb.org/en/latest/tutorial.html instead, the module is now called persistence (lowercased):

    from persistence import Persistence
    

    For more in-depth information, there is also the Writing persistent objects section of the ZODB programming guide.