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
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
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
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
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
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
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
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
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
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
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
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
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
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:
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:
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,
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',
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',
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
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
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
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()),
\
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
23 matches
Mail list logo