Re: [sqlalchemy] Set/clear mapping for some tables only

2016-12-09 Thread Srikanth Bemineni
Hi, Sorry for the delay. Marking the DBsession dirty after a non ORM operation works for now. Zope.sqlalchemy.mark_changed(DBSession()) Thanks for the info Simon Srikanth Bemineni On Tuesday, November 29, 2016 at 9:10:32 AM UTC-6, Mike Bayer wrote: > > Hi Srikanth, answers inline. > > On

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-29 Thread mike bayer
Hi Srikanth, answers inline. On 11/28/2016 10:04 PM, Srikanth Bemineni wrote: Hi Mike, I am using pyramid_tm as transaction manager which is part of the pyramid framework. Is this the third party transaction manager that you are mentioning about ?. That, as well as zope.transaction, yes.

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-29 Thread Simon King
The "transaction" package is a system for coordinating transactions between multiple systems: https://pypi.python.org/pypi/transaction For example, it could coordinate transactions between multiple SQL databases, using 2-phase commit to ensure that either all are committed or none are

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-28 Thread Srikanth Bemineni
Hi Mike, I am using pyramid_tm as transaction manager which is part of the pyramid framework. Is this the third party transaction manager that you are mentioning about ?. Can you please tell us how pyramid_tm, ZopeTransacationExtension and sqlachemy come together. Why are they so many layers

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-28 Thread Simon King
I don't know if this is part of your problem, but: 1. metadata.create_all(Session.connection()) will not mark the session as dirty 2. Session.flush() is a no-op if the session is clean - it won't even fire the "after_flush" event 3. ZopeTransactionExtension uses the after_flush event (or

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-28 Thread mike bayer
On 11/27/2016 09:24 AM, Srikanth Bemineni wrote: Hi Mike, I even tried flushing and committing the transaction. But still the same issue. I was trying to figure out why is getting rolled back. Please see the below stack trace that rollback is normal when the connection is returned to the

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-27 Thread Srikanth Bemineni
Hi Mike, I even tried flushing and committing the transaction. But still the same issue. I was trying to figure out why is getting rolled back. Please see the below stack trace DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension ())) with

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-27 Thread mike bayer
you need to call commit() on a Session in order for the transaction to be committed. Also you should be able to attach session events to the scoped_session object directly, the session event structure will extract the underlying sessionmaker class as the target. On 11/26/2016 01:56 PM,

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-26 Thread Srikanth Bemineni
Hi, May be I celebrated little bit too early. It looks like for no obvious reason the scoped_session rolls back the transaction right at the last moment. Any idea on how to debug this ? View.py with session_shardid(DBSession(),table_hash): Base.metadata.create_all(DBSession().connection())

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-26 Thread Srikanth Bemineni
Hi, Hope this helps others 1. DBSession is scoped_session. Use DBSession() to get the actual session https://pypi.python.org/pypi/zope.sqlalchemy with session_shardid(DBSession(),table_hash): Base.metadata.create_all(DBSession().connection()) 2. AttributeError: 'SessionTransaction'

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread Srikanth Bemineni
Hi, Sorry some of the debug trace was missing from the previous post WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x15dc190 pid: 10256 (default app) Inside session_shardid ** 2016-11-25 21:34:50,808 INFO [sqlalchemy.engine.base.Engine:1140][b 'uWSGIWorker2Core0'] select

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread Srikanth Bemineni
Hi, I was not using the DBSession.connection() while creating the tables when invoking the create_all function on the metadata. After fixing that issue I end with an another issue. It looks like the session(scoped_session), where I set the shard id, and the session that I receive, when the

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread Srikanth Bemineni
Hi, Just trying to integrate the recipe into my pyramid application. Sqlalchemy 1.1.4 How do we put an event on a sessionmaker() managed by scope_session in a pyramid application. This doesn't seem to work. Is the connection already established ? engine = engine_from_config(settings,

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread mike bayer
On 11/25/2016 03:55 PM, Srikanth Bemineni wrote: Hi Mike, The more "high scale" way here if you're really doing hundreds/thousands of different sets of tables is to modify the SQL statements on the way out. That example is here:

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread Srikanth Bemineni
Hi Mike, The more "high scale" way here if you're really doing hundreds/thousands > of different sets of tables is to modify the SQL statements on the way > out. That example is here: > > https://bitbucket.org/zzzeek/sqlalchemy/wiki/UsageRecipes/SessionModifiedSQL > . This does exactly the

Re: [sqlalchemy] Set/clear mapping for some tables only

2016-11-25 Thread mike bayer
On 11/24/2016 11:04 PM, Srikanth Bemineni wrote: Hi, I am using sqlalchemy in my pyramid application. I have situation here, where I need to map a table on the fly in the application during run time. I also dont want to re-map all tables, there are some table which are defined using a

[sqlalchemy] Set/clear mapping for some tables only

2016-11-24 Thread Srikanth Bemineni
Hi, I am using sqlalchemy in my pyramid application. I have situation here, where I need to map a table on the fly in the application during run time. I also dont want to re-map all tables, there are some table which are defined using a declarative base. I need those mapping to remain as is.