Bugs, Problems

Close Database

If a database is not closed properly with the close() method and if the database is removed in the same run, an exception is raised. The following script is correct:

import shutil
import os
import memcom

def rmdir(n):
    if os.path.isdir(n):
        shutil.rmtree(n)
    else:
        return

mcname = 'archives.mc'
db = memcom.db(mcname, 'n')
db.close()
rmdir('archives.mc')

If the line

db.close()

is omitted, an exception is raised.

Replace Entries in Relational Tables

In case you want to replace entries in a relational table on the database you must replace the whole entry if the entry contains more that one int or float. Replacing elements of an entry will not work in this case. Example to replace entries in a sub-table (here: sub-table 123):

# Replace second element of entry 'NODES'
db['ETAB.1][123]['NODES'][1] = 456

This works:

# Extract entry
nodes = db['ETAB.1][123]['NODES']
# modify
nodes[1] = 456
# replace entry
db['ETAB.1][123]['NODES'] = nodes

Reason for this problem: Relational tables on database are not Python dictionaries.