O, I forgot to mention :

<code>
(my-coriolis)chaou...@jogger:~/CODE/TEST/CORIOLIS$ ipython
frPython 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from elixir import sqlalchemy

In [2]: sqlalchemy
Out[2]: <module 'sqlalchemy' from 
'/usr/lib/pymodules/python2.6/sqlalchemy/__init__.pyc'>

In [3]: sqlalchemy.__version__
Out[3]: '0.5.8'

In [4]: import elixir

In [5]: elixir.__version__
Out[5]: '0.7.1'
</code>


--- On Tue, 6/29/10, chaouche yacine <[email protected]> wrote:

> From: chaouche yacine <[email protected]>
> Subject: [elixir] Foreign key constraints not fired ?
> To: [email protected]
> Date: Tuesday, June 29, 2010, 5:33 AM
> Hi list, 
> 
> this is my first post on this list I guess, so please
> forgive my newbiness and my ignorance of this list etiquette
> (if any).
> 
> So here's a little piece of code that illustrates my
> situation on foreign key constraints :
> 
> (briefly : the delete function should break, but it
> doesen't)
> 
> <code>
> 
> from elixir import *
> 
> class BaseModel(Entity):
>     using_options(abstract=True)
> 
>     repr_attr = "name"
> 
>     def __repr__(self):
>         """
>         """
>         return "<%s '%s'
> id='%s'>" %
> (self.__class__.__name__,getattr(self,self.repr_attr,id(self)),self.id)
>     
> class Country(BaseModel):
>     """
>     """
>     using_options(tablename = "countries")
> 
>     name       =
> Field(Unicode)
>     cities     =
> OneToMany("City")
> 
> class City(BaseModel):
>     """
>     """
>     using_options(tablename = "cities")
> 
>     name    = Field(Unicode)
>     country =
> ManyToOne("Country",ondelete="RESTRICT")
> 
> metadata.bind =
> "postgres://auser:somepas...@somedhost/somedb"
> # I use this to issue some raw sql (truncate not supported
> by sqla/elixir ?)
> session.bind = metadata.bind
> drop_all()
> setup_all(True)
> 
> # This line will break if uncommented, because of fk
> constraints
> #session.execute("TRUNCATE TABLE cities")
> session.execute("TRUNCATE TABLE countries CASCADE")
> session.commit()
> 
> # just to make them global
> algeria = None
> algiers = None
> 
> def create():
>     global algeria,algiers
>     algeria = Country(name=u"Algeria")
>     algiers =
> City(name=u"Algiers",country=algeria)
>     session.commit()
>     algeria.delete()
> 
> def delete():
>     global algeria,algiers
>     # THIS DOSEN'T BREAK which is NOT what we
> want
>     algeria.delete()
>     session.flush()
>  
> create()
> delete()
> 
> </code>
> 
> 
> I'm sure I'm missing something, but where ?... 
> 
> Thanks for your help.
> 
> Y.Chaouche
> 
> 
> 
> 
>       
> 
> -- 
> You received this message because you are subscribed to the
> Google Groups "SQLElixir" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlelixir?hl=en.
> 
> 


      

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

Reply via email to