[sqlalchemy] Re: One To Many Polymorphic Association.

2007-08-27 Thread praddy

Currently, unable to find any solution for this problem. I think my
little knowledge with respect to
sqlalchemy is restricting me to get a solution for this issue. Anyone
with somewhat more in-depth
knowledge should be able to find a solution.

Waiting...

Regards,
Pradeep Jindal

On Aug 25, 1:15 am, Pradeep Jindal [EMAIL PROTECTED] wrote:
 On Friday 24 August 2007 19:20:00 Gaetan de Menten wrote:



  You might be interested by:http://techspot.zzzeek.org/?p=13
  (also in the examples directory of SQLAlchemy)

  On 8/24/07, praddy [EMAIL PROTECTED] wrote:
   ##
   from sqlalchemy import *
   meta = BoundMetaData('sqlite://', echo=False)

   # Parents table.
   parents = Table('parents', meta,
   Column(id, Integer, primary_key=True),
   Column(data, String(50), nullable=False)
   )

   # Children_1 Table.
   children_1 = Table('children_1', meta,
   Column(id, Integer, primary_key=True),
   Column(data, String(50), nullable=False)
   )

   # Children_2 Table.
   children_2 = Table('children_2', meta,
   Column(id, Integer, primary_key=True),
   Column(data, String(50))
   )

   # Association Table.
   # This is a generic table which can relate anything to parent.
   assoc = Table('assoc', meta,
   # parents.c.id
   Column(parent_id, Integer, ForeignKey(parents.c.id)),
   # associate's id either children_1.c.id or children_2.c.id or any
   other child.
   Column(assoc_id, Integer),
   # Which can be either 'child_1' or 'child_2' for now (can be used
   for extending children
   # type, decides which table to look in.
   Column(assoc_type, String(20))
   )
   ###

   I am a novice with respect to sqlalchemy  may be RDBMS as well.
   How would you like to work on this scenario to achieve backwards
   cascading (may not be the right word) which means when one deletes
   one specific child from children_1 table (for example), there should
   not be any
   association entry, which associates that child to the parent, in the
   association table as well?

 Thanks for the reply. I have already gone through that article, but was unable
 to figure out the solution. Anyways, I will give it one more try. Please note
 that this scenario is already there and I can't make any changes to the
 tables at all.

 Thanks
 - Pradeep Jindal


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] One To Many Polymorphic Association.

2007-08-24 Thread praddy

##
from sqlalchemy import *
meta = BoundMetaData('sqlite://', echo=False)

# Parents table.
parents = Table('parents', meta,
Column(id, Integer, primary_key=True),
Column(data, String(50), nullable=False)
)

# Children_1 Table.
children_1 = Table('children_1', meta,
Column(id, Integer, primary_key=True),
Column(data, String(50), nullable=False)
)

# Children_2 Table.
children_2 = Table('children_2', meta,
Column(id, Integer, primary_key=True),
Column(data, String(50))
)

# Association Table.
# This is a generic table which can relate anything to parent.
assoc = Table('assoc', meta,
# parents.c.id
Column(parent_id, Integer, ForeignKey(parents.c.id)),
# associate's id either children_1.c.id or children_2.c.id or any
other child.
Column(assoc_id, Integer),
# Which can be either 'child_1' or 'child_2' for now (can be used for
extending children
# type, decides which table to look in.
Column(assoc_type, String(20))
)
###

I am a novice with respect to sqlalchemy  may be RDBMS as well.
How would you like to work on this scenario to achieve backwards
cascading (may not be the right word) which means when one deletes
one specific child from children_1 table (for example), there should
not be any
association entry, which associates that child to the parent, in the
association table as well?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---