Hi All,

    at the end, I finally cracked the problem with the tree-structured
database with SQLAlchemy. I still have however a problem.
I am using a "physical" database, not an in-memory one. I have
declared my Tables as follows:

trees = Table('treenodes', metadata,
              Column('node_id', Integer,
Sequence('treenode_id_seq',optional=False), primary_key=True),
              Column('parent_node_id', Integer,
ForeignKey('treenodes.node_id'), nullable=True),
              Column('node_name', String(500), nullable=False),
              Column('formattedname', String(500), nullable=False),
              Column('data_ident', Integer, ForeignKey('treedata.data_id'))
              )


treedata = Table("treedata", metadata,
                 Column('data_id', Integer, primary_key=True),
                 Column('value', String(100), nullable=False)
                 )

mapper(TreeNode, trees, properties=dict(id=trees.c.node_id,
                                        name=trees.c.node_name,
                                        parent_id=trees.c.parent_node_id,
                                        children=relation(TreeNode,
cascade="all", backref=backref("parent",
remote_side=[trees.c.node_id]),

collection_class=NodeList),
                                        data=relation(mapper(TreeData,
treedata, properties=dict(id=treedata.c.data_id)),

cascade="all,delete,delete-orphan", lazy=False))


Everything goes ok, I can save my data to a database file called
MyDatabase.db. After saving few items, the database size is about 180
Kb. So far so good. But when I delete one or more items (also if I
delete all the items) using:

self.session.delete(bad_node)
self.session.flush()
self.session.clear()

By printing the node names, I know that bad_node is no more there, but
its data seems to still live in the database. I mean, even if I delete
*all* the items, the database size is still 180 Kb, no matter how much
I flush(), clear(), close() and reopen the database.
I am sure I am missing something. Which is the usual approach to
delete *permanently* things from a database?

Thank you in advance for your suggestions.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to