[sqlalchemy] How to enter value for foriegn key field via sqlalchemy

2015-06-22 Thread sudheesh ks
I have models: { class Post(db.Model): id = db.Column(db.Integer, primary_key = True) body = db.Column(db.String(2000)) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) comments = db.relationship('Comment', backref='parent_post', lazy='dynamic') class

Re: [sqlalchemy] How to enter value for foriegn key field via sqlalchemy

2015-06-22 Thread sudheesh ks
So thanks... It worked. I made that mistake in code and had been trying to solve that for 2 days. On Tue, Jun 23, 2015 at 1:20 AM, Simon King si...@simonking.org.uk wrote: On Mon, Jun 22, 2015 at 8:44 PM, sudheesh ks kssudheesh...@gmail.com wrote: I have models: { class Post(db.Model):

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2015-06-22 Thread Mike Bayer
you can check for new/dirty/deleted in after_flush, these collections haven't yet been reset. after_flush_postexec is where they are reset. On 6/22/15 7:45 PM, imali...@uber.com wrote: Why wouldn't you check for new, dirty deleted 'before_flush' instead of 'after_flush'. Would 'after_flush'

[sqlalchemy] In ORM relationship list don't get refreshed even after refreshing

2015-06-22 Thread Balaji Pattewar
Hi all, I am using simple SQLALCHEMY implementation. I have two classes Svc, Mani class Svc(Base): ''' class to map 'service' table in database ''' __tablename__ = 'svc' __table_args__ = {'autoload': True} manis = relationship('Mani') What I found that upon

Re: [sqlalchemy] How to determine if a session has any uncommitted changes

2015-06-22 Thread imalison
Why wouldn't you check for new, dirty deleted 'before_flush' instead of 'after_flush'. Would 'after_flush' even work? On Thursday, October 9, 2014 at 1:34:58 PM UTC-4, Tom Dalton wrote: Brilliant, the after_flush event sounds like the way to go. I guess my event handlers would be:

Re: [sqlalchemy] In ORM relationship list don't get refreshed even after refreshing

2015-06-22 Thread Mike Bayer
1. check on the isolation level you're using, and as a guarantee that you read new rows, make sure the second reader session is beginning its transaction *after* the first transaction is completed. 2. if the second session wishes to re-read the rows within its own transaction, and you are

[sqlalchemy] how to properly remove a one-to-one relationship ?

2015-06-22 Thread laurent
Hello all, What is the proper way to fully remove a one-to-one related object ? I I do Session.delete(a.b) print a.b # b is still here ... What am I missing ? Thanks, Laurent -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe

Re: [sqlalchemy] How to enter value for foriegn key field via sqlalchemy

2015-06-22 Thread Simon King
On Mon, Jun 22, 2015 at 8:44 PM, sudheesh ks kssudheesh...@gmail.com wrote: I have models: { class Post(db.Model): id = db.Column(db.Integer, primary_key = True) body = db.Column(db.String(2000)) user_id = db.Column(db.Integer, db.ForeignKey('user.id')) comments =