Hi, i am in the transition to use Durus more often as my favourit database and would also like to switch from relational to object-oriented. Programing language is Python (2.4.1), i have Durus 3.1 installed from source on my Kubuntu breezy Linux system. (There seems to be no ubuntu|deb-package available!) I was not able to find code samples (simple and not so simple) via Google or even reading in this mailing-list. To make a longer story short: I have troubles with (my) Durus in my somewhat larger programs. I see "memory allocation errors" very often, so that atm durus is not usable for me. It just dies, no messages to follow :=( Little testing programs do work though, i have pasted one into this email (hope thats the correct way, the python-format will most likely not survive). I'm hoping that : 1. someone could tell me if thats the way to work with OODBs|Durus, or give some hints how to do better? Im especially interessted in bringing some form of hierarchy|separation into Durus. 2. that this will help others to get started (especially when the code is good) 3. I will find out something to use Durus in my bigger programs. [BTW those progs are a bit bigger, but the demand for Durus is imho rather small] Thanks in advance and waiting to here from you Kai The rest is my (working) demo program: #!/usr/bin/python # -*- coding: utf-8 -*- """ This is a test to bring a hierarchy into durus-ODB. To separate a part 'Products' from some other part 'Bookings'. 100 persistent dictionaries are stored in the persistent_dict 'Products' 100 persistent dictionaries are stored in the persistent_dict 'Bookings' 1. Start Durus-Server before running that: durus -s --file newfile.durus 2. Run this program with option -init 3. Stop the Durus-server, and restart durus -s --stop durus -s --file newfile.durus 4. Run this program with option -read """ import sys import random import socket from durus.client_storage import ClientStorage from durus.connection import Connection from durus.persistent import Persistent from durus.persistent_dict import PersistentDict from durus.persistent_list import PersistentList from durus.error import ProtocolError SIZE=100 def rand(limit=100): return random.randint(1,limit) if len(sys.argv)>1: arg = sys.argv[1] else: arg = "-init" print "arg=", arg try: connection = Connection(ClientStorage()) except socket.error: print "Durus-Server is not running. Start 'durus -s --file newfile.durus' !" sys.exit(2) root=connection.get_root() connection.commit() # ?? if arg=="-init": # use this for the first time print "Filling the empty ODB" root['Products']=PersistentDict() # ?? root['Bookings']=PersistentDict() connection.commit() # ?? ProdDB=root['Products'] # a Shortcut BookDB=root['Bookings'] # a Shortcut for i in range(SIZE): normalDict={'aInt' : rand(), 'aFloat' : 2.22, # simple Float, no persistance needed 'aString': 'DurusProducts', # simple String, no persistance needed 'aTuple' : (rand(5),rand(5),rand(5)) # simple tuple, no persistance needed } keyID="key%i" % i ProdDB[keyID]=PersistentDict(normalDict) connection.commit() print "Stored %i Dictionaries in part ProdDB" % SIZE print "retrieving the one named 'key7'" k7=ProdDB['key7'] print type(k7), k7.keys() print k7['aInt'], k7['aTuple'] for i in range(SIZE): # same again for Bookings normalDict={'aInt' : rand(), 'aFloat' : 2.22, 'aString': 'DurusBookings', 'aTuple' : (rand(5),rand(5),rand(5)) } keyID="key%i" % i BookDB[keyID]=PersistentDict(normalDict) connection.commit() print "Stored %i Dictionaries in part BookDB" % SIZE print "retrieving the one named 'key7'" k7=BookDB['key7'] print type(k7), k7.keys() print k7['aInt'], k7['aTuple'] if arg=="-read": # use after the first time print "Reading from the filled ODB" if not root.has_key('Products'): print "no Dictionary 'Products' found !!" sys.exit(1) ProdDB=root['Products'] # a Shortcut BookDB=root['Bookings'] # a Shortcut for prod in ProdDB: p=ProdDB[prod] print prod, p['aInt'], p['aFloat'], p['aString'], p['aTuple'] print 50* "=" for book in BookDB: p=BookDB[book] print book, p['aInt'], p['aFloat'], p['aString'], p['aTuple'] print 50*"=" print "%i Entries in ProdDB" % len(ProdDB) print "%i Entries in BookDB" % len(BookDB)