Audrius Kažukauskas
Hi Audrius,

Your code works like a charm. Thank you so much for your help!
I really appreciate!

On Wednesday, December 5, 2012 12:53:25 PM UTC-5, Audrius Kažukauskas wrote:
>
> On Wed, 2012-12-05 at 09:07:20 -0800, junepeach wrote: 
> > I just did a testing, basically copied and ran the code of below link: 
> > http://docs.sqlalchemy.org/en/rel_0_8/core/tutorial.html 
> > in the middle of process, I copied and ran below code: 
> > 
> > from sqlalchemy.engine import Engine 
> > from sqlalchemy import event 
> > 
> > @event.listens_for(Engine, "connect") 
> > def set_sqlite_pragma(dbapi_connection, connection_record): 
> >     cursor = dbapi_connection.cursor() 
> >     cursor.execute("PRAGMA foreign_keys=ON") 
> >     cursor.close() 
> > 
> > then insert a couple rows to both user and addresses tables.  I didn't 
> > insert user id '3', however I could insert foreign key user id '2' 
> > into addresses table. So foreign key constraint was not enforced. 
>
> You need to register the event handler before you make any attempts to 
> connect to your database.  See attached the example that works as 
> expected (fails with IntegrityError exception due to foreign key 
> constraint). 
>
> -- 
> Audrius Kažukauskas 
> http://neutrino.lt/ 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/yyx_2Fc_sWgJ.
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/sqlalchemy?hl=en.

Reply via email to