[sqlalchemy] [SQLAlchemy RD] Working of Session in thread

2013-10-10 Thread sajuptpm
Could someone please explain, Howto sqlalchemy creating new Session and connection inside the thread. Please check the attached programme and output. I went through the doc http://docs.sqlalchemy.org/en/latest/orm/session.html#thread-local-scope and find that sqlalchemy using

[sqlalchemy] How to update PickleType column using DBSession.execute()

2013-05-31 Thread sajuptpm
How to update PickleType column using DBSession.execute() class MyTable(DeclarativeBase): __tablename__ = 'mytable' context = Column(PickleType) *Attempt 1 * context = {k1:{n1:bbla}, k2:{n2:bbla}} context = pickle.dumps(context) DBSession.execute(update mytable set

Re: [sqlalchemy] How to change polymorphic_identity dynamically

2013-05-08 Thread sajuptpm
Hi Michael Bayer, 1) I tried your suggestion, but it not updating the value of type column in the database. instance_of_B.__class__ = C_Class instance_of_B.type = type_c 2) * So, i tried like this, and it updating he value of type column in the database. * What you think?, is it a good way to

[sqlalchemy] How to change polymorphic_identity dynamically

2013-05-06 Thread sajuptpm
Hi, * I have a table A with __mapper_args__ = {'polymorphic_on': type} * Table B C and D are inherited from A with polymorphic_identity type_b, type_c and type_d respectively I want to change the value of polymorphic_identity for an instance of class B, how do it ?? I tried like this, but

[sqlalchemy] Re: How to change polymorphic_identity dynamically

2013-05-06 Thread sajuptpm
Hi, I also tried like this, But not working instance_of_B.__mapper_args__[polymorphic_identity] = type_c DBSession.add(instance_of_B) transaction.commit(); and instance_of_B.__mapper__.polymorphic_identity = type_c DBSession.add(instance_of_B) transaction.commit(); Thanks, -- You received

Re: [sqlalchemy] How to get update done by one transaction in another transaction

2013-04-28 Thread sajuptpm
Hi Michael Bayer, I tried with execution_options, but getting *AttributeError: 'ScopedSession' object has no attribute 'execution_options'.* Note, In my code, I don't have access to create_engine and connection object, since they are defined at lower level. But I can access DBSession, since

Re: [sqlalchemy] How to get update done by one transaction in another transaction

2013-04-28 Thread sajuptpm
Hi Michael Bayer, I am getting following errors 1) engine = DBSession.bind DBSession.commit() assert self.transaction_manager.get().status == ZopeStatus.COMMITTING, Transaction must be committed using the transaction manager *AssertionError: Transaction must be committed using the transaction

Re: [sqlalchemy] How to get update done by one transaction in another transaction

2013-04-27 Thread sajuptpm
Hi Michael Bayer, I can't set isolation_level='SERIALIZABLE' at global level, since it affect behaviour of other existing operations of my application. So I done following changes where-ever I want to get changes committed by other transactions 1) Set Session isolation_level to READ-COMMITTED

Re: [sqlalchemy] How to get update done by one transaction in another transaction

2013-04-26 Thread sajuptpm
Hi Michael Bayer, Is there any way to dynamically change Transaction Isolation Level ?? I want to do it only for a particular operation. So I can't set it at Engine or Connection Level, right ?? I am using turbogears + Sqlalchemy with default isolation_level. What is the default

[sqlalchemy] How to get update done by one transaction in another transaction

2013-04-25 Thread sajuptpm
Hi, Suppose we have two transactions T1 and T2. Both transactions trying to update same row ROW1. Suppose both transactions are started simultaneously. T1 first updated ROW1 and commit it. In my case T2 not getting the update done by T1. If run commit in T2 and query ROW1 again, then I can

[sqlalchemy] How to release sqlalchemy with_lock

2013-04-25 Thread sajuptpm
Hi, I have a locking system like this class LockManager: def get_lock(self, id): lock_m=DBSession.query(Locker).with_lockmode(update).\ filter(Locker.id==id).all() if len(lock_m) == 0: lm=Locker(id) DBSession.add(lm) def

Re: [sqlalchemy] Re: ObjectDeletedError: Instance 'xxx' has been deleted

2012-11-21 Thread sajuptpm
Hi, Michael Bayer. Thanks, that example is really helpful. In your example I used *Session.object_session*http://docs.sqlalchemy.org/en/latest/orm/session.html#sqlalchemy.orm.session.Session.object_sessionmethod to verify that main_method and method1 running in two different sessions. But my

[sqlalchemy] how to implement nested scoped_session

2012-11-17 Thread sajuptpm
Hi, Getting error when nesting scoped_session http://stackoverflow.com/questions/13330245/how-to-use-nested-transaction-with-scoped-session-in-sqlalchemy https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/E8QEtj35TEY Thanks -- You received this message because you are subscribed

[sqlalchemy] ObjectDeletedError: Instance 'xxx' has been deleted

2012-11-16 Thread sajuptpm
The code bellow throwing error ObjectDeletedError: Instance 'xxx' has been deleted. when an exception throwing from method1. How fix this issue. def main_method(): DBSession.add(db_obj1) DBSession.fush() for x in lst: method1(db_obj1.id) def method1(id): try:

[sqlalchemy] Re: ObjectDeletedError: Instance 'xxx' has been deleted

2012-11-16 Thread sajuptpm
The code bellow throwing error ObjectDeletedError: Instance 'xxx' has been deleted. when a exception throwing from method1. Eroor in line method1(db_obj1.id), db_obj1.id failing. How fix this issue. def main_method(): DBSession.add(db_obj1) DBSession.fush() for x in lst:

Re: [sqlalchemy] Re: ObjectDeletedError: Instance 'xxx' has been deleted

2012-11-16 Thread sajuptpm
H, Michael Bayer Thanks You are correct, the rollback in method1 rollbacking transaction in main_method. I want to isolate transaction in main_method from rollback in method1. I attached more code. from sqlalchemy.orm import scoped_session, sessionmaker maker = sessionmaker(autoflush=True,

[sqlalchemy] sqlalchemy.exc.NotSupportedError: (NotSupportedError) (1286, Unknown table engine 'InnoDB') set storage_engine='InnoDB' ()

2012-03-20 Thread sajuptpm
Hi, Getting following error while doing setup-app Running setup_config() from site.websetup Creating tables check if database exists create database Traceback (most recent call last): File /home/sa/cms/tg2env/bin/paster, line 8, in module load_entry_point('PasteScript==1.7.3',

[sqlalchemy] Re: howto Sqlalchemy atomic transaction ??

2011-11-21 Thread sajuptpm
Model class VDCTemplates(DeclarativeBase): __tablename__='cd_vdc_templates' id = Column(Unicode(50), primary_key=True) vdc_id=Column(Unicode(50), ForeignKey('cd_vdc.id', ondelete=CASCADE)) template_id=Column(Unicode(50), ForeignKey('cd_account_templates.id',

[sqlalchemy] howto Sqlalchemy atomic transaction ??

2011-11-20 Thread sajuptpm
Hi, http://dpaste.com/659618/ -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more

[sqlalchemy] Join query with MAX

2011-11-17 Thread sajuptpm
i have a join query that using aggregate function MAX and its output look like (103,) or (None, ), How check that out of that query is not None. ?? saju_m i know we can not use -- if result:, only option is i think --- if result[0]: , Any other way ? -- You received this message

[sqlalchemy] sqlalchemy check select query execution time

2010-10-28 Thread sajuptpm
How check select query execution time using sqlalchemy. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] SQLAlchemy subquery to find variance

2010-09-17 Thread sajuptpm
DBSession.query(func.length(class_name.cpu_util), (DBSession.query(func.variance(class_name.util)).\ filter(class_name.entity_id==entity_id).filter(class_name.metric_type==metric_type). \ filter(class_name.cdate=from_date).filter(class_name.cdate=to_date).all()), \

[sqlalchemy] func.variance() in sqllalchemy

2010-09-03 Thread sajuptpm
How calculate variance in sqlalchemy No function func.variance() in sqllalchemy -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to