Open and close a ceda PersistStore in Python

This example assumes you have installed the pyceda module. It demonstrates the calls used to open and close a PersistStore. This essentially creates an empty database.

Note that OpenPersistStore can throw exceptions and in a real program it would be appropriate to deal with these exceptions

Using your favorite text editor, write a file named open-and-close-database.py as follows:


# open-and-close-database.py
# This is python

import pyceda

ceda = pyceda.ceda

# Create a database named 'mydatabase'
pstore = ceda.OpenPersistStore(
    'mydatabase',
    ceda.EOpenMode.OM_CREATE_ALWAYS,
    ceda.PersistStoreSettings())

# Close the database
pstore.Close()

In a bash terminal run open-and-close-database.py as follows:


# bash
python open-and-close-database.py

This will write a single 512kB file named 'mydatabase' in the current directory.