[sqlalchemy] Re: Come on, share your sqlalchemy powered sites with others.//Fwd: A tornado powered site to show any project powered sites(open source)

2010-08-23 Thread Stone Puzzle
It's official online now after two weeks beta testing.
A bunch of sites already been submitted, come on and enjoy it.

Below list some popular projects' sub-sites:

http://sqlalchemy.poweredsites.org SQLAlchemy powered sites.

http://ror.poweredsites.org  http://ror.poweredsites.org/Ruby on
Rails powered sites

http://django.poweredsites.org Django powered sites

http://mongodb.poweredsites.org MongoDB powered sites.

http://jquery.poweredsites.org jQuery powered sites

http://python.poweredsites.org Python powered sites

http://yii.poweredsites.org Yii framework powered sites.

http://flask.poweredsites.org Flask powered sites.

On Sun, Aug 8, 2010 at 12:56 PM, Stone Puzzle stonepuz...@gmail.com wrote:

 SqlAlchemy powered sites list  http://sqlalchemy.poweredsites.org

 -- Forwarded message --
 From: Felinx Lee felinx@gmail.com
 Date: Tue, Aug 3, 2010 at 2:29 PM
 Subject: A tornado powered site to show any project powered sites(open
 source)
 To: python-torn...@googlegroups.com


  I am very pleased to announce the beta release of http://poweredsites.org(A 
 tornado powered site to show any project powered sites)

 *What powered sites?*

 We are always curious about that when we navigating exciting sites.
 PoweredSites is a good site to share with others about a project or service
 powered sites, eg. jQuery powered sites http://jquery.poweredsites.org/,
 Torando powered sites http://tornado.poweredsites.org/. PoweredSites is
 also a good place to show your project's power if you are a project owner.

 PoweredSites source code is opened to the community under Apache License
 V2, the source code is available at
 http://www.bitbucket.org/felinx/poweredsites, it's develop by python
 http://www.python.org/and tornado http://www.tornadoweb.org/. I opened
 everything except the OpenID API key:), so you can setup a web site using
 the code easily.

 Currently, twitter,facebook,friendfeed openid login are no well tested
 because those web sites are blocked in China. And some of features are still
 under developing, eg. re-edit a project or site and wiki for every project.

 *I hope that you will enjoy the site and the source code.* *I hope some
 guys can join me to make the site better.*

 Please don't hesitate to submit your 
 projectshttp://poweredsites.org/submit/projectpreor submit
 web sites http://poweredsites.org/submit/sitepre to
 http://poweredsites.org/.

 And any bug reports are welcome.

 For detail information and comments, please visit here.
 http://blog.poweredsites.org/entry/poweredsites-beta-online

 BTW: You can submit and find tornado powered sites from
 http://tornado.poweredsites.org now.

 Cheers.

 --
 Felinx Lee

 What powered the sites?
 http://poweredsites.org

 What can change the nature of a man?(Planescape Torment)
 http://en.wikipedia.org/wiki/Planescape:_Torment




-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] How to declare many-to-one in this example?

2010-08-23 Thread Freewind
I'm new to python(sqlalchemy), and I'm learning to build web site with
pylons and sqlalchemy.

I have a problem when I declare the relationship between models. I've
tried it several hours, but failed. But I think it should be a basic
question.

I have two classes: User and Article, user can create articles, and
modified the other people's article(like wiki).
So a user has created-articles and edited-articles.


class Article(Base):
__tablename__ = 'articles'

id = Column(Integer, primary_key=True)
title = ...

user_id = Column(Integer, ForeignKey('users.id'))
editor_id = Column(Integer, ForeignKey('users.id'))

# relations
user = relationship('User', backref='articles') # - has error


class User(Base):
pass


But there is an error displayed:
InvalidRequestError: One or more mappers failed to compile. Exception
was probably suppressed within a hasattr() call. Message was: Could
not determine join condition between parent/child tables on
relationship Article.user. Specify a 'primaryjoin' expression. If this
is a many-to-many relationship, 'secondaryjoin' is needed as well.

I tried to add `primaryjoin` to the line('has error'), but don't know
what it should be. I tried some codes, but none works.

Thank you in advance!

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Polymorphic across foreign key

2010-08-23 Thread Michael Bayer

On Aug 22, 2010, at 8:45 AM, Eduardo Robles Elvira wrote:

 On May 15 2008, 6:27 pm, Michael Bayer mike...@zzzcomputing.com
 wrote:
 On May 15, 2008, at 12:12 PM, J. Cliff Dyer wrote:
 How can I use this field for polymorphism?  Is it possible?
 
 polymorphicdiscriminators are currently table-local scalar columns.  
 So if you had a many-to-one of discriminators, youd currently have to  
 encode the discriminator to the primarykeyidentifier of each  
 discriminotor.  We will eventually allow a python function to be used  
 as a discriminator as well which you can use to add a level of  
 abstraction to this (you'd preload the list of discriminiator objects  
 and again map based on primarykey).
 
 Hello!
 
 Two years later.. :P Are we going to get a python function to be used
 as a discriminator soon? I would think that it would not be very
 difficult to implement, right? As shown in my previous emails in the
 thread Model factory, that would solve my problem.

Discriminator functions don't solve your issue.  Your table already has a 
discriminator column, so in that regard, determination of discriminiator, 
which is all that proposed function would ever do, is already provided by the 
built in functionality.

You're looking to rig a non-SQLAlchemy creational pattern into your objects.   
The MapperExtension method create_instance() provides this capability.
Another option is to just use @reconstructor, and just set self.__class__ = 
whatever class you want.

I agree with other posters that the whole idea is a little hacky and if it were 
me, I would ensure that all Job subclasses are configured and mapped ahead of 
time.  Failing that, if I truly needed to have module paths in the database 
(which I wouldn't, since I think encoding language-specific constructs in a 
relational database is a bad idea), I would either have my app do a SELECT 
DISTINCT of all those modules at startup, pre-load all the classes and map 
them, or, I'd have Job load an impl based on that module information and 
proxy methods to the dynamically loaded object (which is not very different 
from the @reconstructor approach except for structure).


 I have the python
 function already written, but I don't know how to make sqlalchemy call
 to it. I thought that using a composite field should work, but it
 doesn't because as you say, it's not a table-local scalar column. If
 the problem is the proxy_set is not set, maybe I can set the proxy_set
 var to the composite_field somehow?



 
 Regards,
   Eduardo Robles Elvira.
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] How do I set the transaction isolation level in SQLAlchemy for PostgreSQL?

2010-08-23 Thread Michael Bayer

On Aug 22, 2010, at 10:44 PM, Mahmoud Abdelkader wrote:

 Hi Michael, 
 
 Thanks for responding. Will there be any backward incompatibility issues with 
 a SQLAlchemy upgrade to the tip? We're using SQLAlchemy in a rather large 
 project.
 
 Thanks!
 Mahmoud

If your app sticks to traditional SQLAlchemy patterns, the upgrade to 0.6 
shouldn't have issues - the biggest one could be that you'd have to upgrade 
your sqlalchemy-migrate if you're on an older version, and I believe they had 
an API change.

An overview of SQLAlchemy changes from 0.5 - 0.6 is at 
http://www.sqlalchemy.org/trac/wiki/06Migration .

Note that the PoolListener approach will work perfectly fine in 0.5, that's 
what the isolation_level argument in 0.6 uses in any case.   Docs are 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/interfaces.html?highlight=poollistener#sqlalchemy.interfaces.PoolListener
 .







 
 On Sat, Aug 21, 2010 at 10:51 AM, Michael Bayer mike...@zzzcomputing.com 
 wrote:
 
 On Aug 19, 2010, at 6:32 PM, Mahmoud Abdelkader wrote:
 
 NOTE: I originally posted this question to stack overflow, 
 http://stackoverflow.com/questions/3518863/how-do-i-set-the-transaction-isolation-level-in-sqlalchemy-for-postgresql
  , but I haven't received an answer yet. If I find the answer here, I'll 
 send it over to stackoverflow for thoroughness.
 
 We're using SQLAlchemy declarative base and I have a method that I want 
 isolate the transaction level for. To explain, there are two processes 
 concurrently writing to the database and I must have them execute their 
 logic in a transaction. The default transaction isolation level is READ 
 COMMITTED, but I need to be able to execute a piece of code using 
 SERIALIZABLE isolation levels.
 
 Please use the isolation_level argument to create_engine() 
 (http://www.sqlalchemy.org/docs/reference/dialects/postgresql.html?highlight=isolation_level#transaction-isolation-level)
   and use the latest tip of SQLAlchemy 
 (http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz) until 0.6.4 is 
 released, as there was a psycopg2-specific bug fixed recently regarding 
 isolation level.
 
 The approach you have below does not affect the same connection which is 
 later used for querying - you'd instead use a PoolListener that sets up 
 set_isolation_level on all connections as they are created.
 
 
 
 
 
 from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
 from psycopg2.extensions import ISOLATION_LEVEL_READ_COMMITTED
 from psycopg2.extensions import ISOLATION_LEVEL_SERIALIZABLE
 
 class OurClass(SQLAlchemyBaseModel):
 
 @classmethod
 def set_isolation_level(cls, level=ISOLATION_LEVEL_SERIALIZABLE):
 cls.get_engine().connect().connection.set_isolation_level(level)
 
 
 @classmethod
 def find_or_create(cls, **kwargs):
 try:
 return cls.query().filter_by(**kwargs).one()
 except NoResultFound:
 x = cls(**kwargs)
 x.save()
 return x
 I am doing this to invoke this using a transaction isolation level, but it's 
 not doing what I expect. The isolation level still is READ COMMITTED from 
 what I see in the postgres logs. Can someone help identify what I'm doing 
 anythign wrong?
 
 I'm using SQLAlchemy 0.5.5
 
 class Foo(OurClass):
 
 def insert_this(self, kwarg1=value1):
 # I am trying to set the isolation level to SERIALIZABLE
 try:
 self.set_isolation_level()
 with Session.begin():
 self.find_or_create(kwarg1=value1)
 except Exception:  # if any exception is thrown...
 print I caught an expection.
 print sys.exc_info()
 finally:
 # Make the isolation level back to READ COMMITTED
 self.set_isolation_level(ISOLATION_LEVEL_READ_COMMITTED)
 
 
 
 Appreciate the assistance!
 Thanks
 Mahmoud
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.

-- 
You received this message because you are 

[sqlalchemy] DB tables, check exists before creation? duplicate and rename table in sqlalchemy?

2010-08-23 Thread keekychen.shared
 Dear All,

I have questions in coding my application using sqlalchemy on database
tables.

1. how to create table if not exists in metadata.create_all(engine)
   I googled and fould this
http://www.mail-archive.com/sqlalchemy-us...@lists.sourceforge.net/msg02121.html;
but I found no keywords matched checkexists=True in the document for
version 0.6.4

2. how to duplicate a table with name in sqlalchemy?
   I posted a question in
http://stackoverflow.com/questions/3545140/sqlalchemy-duplicate-table-rename-table;
but seems still no answer.

3. how to rename a table in sqlalchemy?

Thanks for any hints and answer.


Yours,

KC
 




-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] DB tables, check exists before creation? duplicate and rename table in sqlalchemy?

2010-08-23 Thread Daniel Kluev
On Tue, Aug 24, 2010 at 2:04 AM, keekychen.shared 
keekychen.sha...@gmail.com wrote:

  Dear All,

 I have questions in coding my application using sqlalchemy on database
 tables.

 1. how to create table if not exists in metadata.create_all(engine)
   I googled and fould this
 
 http://www.mail-archive.com/sqlalchemy-us...@lists.sourceforge.net/msg02121.html
 
 but I found no keywords matched checkexists=True in the document for
 version 0.6.4


create_all() does this by default.

-- 
With best regards,
Daniel Kluev

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] How to declare many-to-one in this example?

2010-08-23 Thread Michael Bayer

On Aug 23, 2010, at 5:37 AM, Freewind wrote:

 I'm new to python(sqlalchemy), and I'm learning to build web site with
 pylons and sqlalchemy.
 
 I have a problem when I declare the relationship between models. I've
 tried it several hours, but failed. But I think it should be a basic
 question.
 
 I have two classes: User and Article, user can create articles, and
 modified the other people's article(like wiki).
 So a user has created-articles and edited-articles.
 
 
 class Article(Base):
__tablename__ = 'articles'
 
id = Column(Integer, primary_key=True)
title = ...
 
user_id = Column(Integer, ForeignKey('users.id'))
editor_id = Column(Integer, ForeignKey('users.id'))
 
# relations
user = relationship('User', backref='articles') # - has error
 
 
 class User(Base):
pass
 
 
 But there is an error displayed:
 InvalidRequestError: One or more mappers failed to compile. Exception
 was probably suppressed within a hasattr() call. Message was: Could
 not determine join condition between parent/child tables on
 relationship Article.user. Specify a 'primaryjoin' expression. If this
 is a many-to-many relationship, 'secondaryjoin' is needed as well.
 
 I tried to add `primaryjoin` to the line('has error'), but don't know
 what it should be. I tried some codes, but none works.


you want to say this:

class Article(Base):
   __tablename__ = 'articles'

   id = Column(Integer, primary_key=True)

   user_id = Column(Integer, ForeignKey('users.id'))
   editor_id = Column(Integer, ForeignKey('users.id'))

   user = relationship('User', backref='articles', 
primaryjoin=Article.user_id==User.id)


class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)


this to resolve the ambiguity of how Article would join to User, given that 
there are two different foreign keys that reference the 'users' table.

Background documentation is at:

http://www.sqlalchemy.org/docs/mappers.html?highlight=primaryjoin#specifying-alternate-join-conditions-to-relationship

the quoting is specific to declarative:

http://www.sqlalchemy.org/docs/reference/ext/declarative.html?highlight=primaryjoin#configuring-relationships




 
 Thank you in advance!
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] DB tables, check exists before creation? duplicate and rename table in sqlalchemy?

2010-08-23 Thread Michael Bayer

On Aug 23, 2010, at 11:04 AM, keekychen.shared wrote:

 Dear All,
 
 I have questions in coding my application using sqlalchemy on database
 tables.
 
 
 2. how to duplicate a table with name in sqlalchemy?
   I posted a question in
 http://stackoverflow.com/questions/3545140/sqlalchemy-duplicate-table-rename-table;
 but seems still no answer.

method 1 - produce your Table object with a callable:

def new_table(name, metadata):
return Table(name, metadata,
  Column('id',Integer,primary_key=True),
  Column('name',String),
  Column('fullname',String),
  Column('password',String)
)


users = new_table('users', metadata)
users001 = new_table('users_001', metadata)

method 2 - adapt the source code from the tometadata() method of Table, which 
copies a Table to a new MetaData.   This makes use of the copy() method of 
Column and Constraint.

def copy_my_table(name, table):
args = []
for c in table.columns:
args.append(c.copy())
for c in table.constraints:
args.append(c.copy())
return Table(name, table.metadata, *args)



 
 3. how to rename a table in sqlalchemy?

you must issue the appropriate ALTER statements to your database to change the 
name of the table. As far as the Table metadata itself, you can attempt to 
set table.name = 'newname', and re-place the Table object within 
metadata.tables with its new name, but this may have lingering side effects 
regarding foreign keys that reference the old name.  In general, the pattern is 
not supported - its intended that a SQLAlchemy application runs with a fixed 
database structure (only new tables can be added on the fly).

You can also check out the Migrate project which allows migrations, but only in 
the context of a migration script, not a running application.


-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] rollbacks on select

2010-08-23 Thread Tarek Ziadé
Hello,

I use the default options to run queries via sql expressions and I've
noticed that SQLAlchemy does a rollback
after every select using the mysql default engine. These rollback are
not really useful and eat 15% of the CPU time.

Is this a normal behavior, part of the auto commit custom strategy
SQLAlchemy implements ?

If yes, is there a way to avoid those extra rollbacks ?

Regards
Tarek

-- 
Tarek Ziadé | http://ziade.org

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] rollbacks on select

2010-08-23 Thread Michael Bayer


Sent from my iPhone

On Aug 23, 2010, at 8:29 PM, Tarek Ziadé ziade.ta...@gmail.com wrote:

 Hello,
 
 I use the default options to run queries via sql expressions and I've
 noticed that SQLAlchemy does a rollback
 after every select using the mysql default engine. These rollback are
 not really useful and eat 15% of the CPU time.
 
 Is this a normal behavior, part of the auto commit custom strategy
 SQLAlchemy implements ?
 
 If yes, is there a way to avoid those extra rollbacks ?

Because we're using a connection pool, putting the connection back into the 
pool without a rollback means you throw existing transactional locks and state 
into the pool as well, holding them open indefinitely and generally causing 
problems for subsequent usages of those pooled connections.

However, we get a complaint about every 6 months from a mysql myisam user, who 
uses many ad-hoc connection checkouts (which in itself is a little unusual) and 
who would rather not have it (as myisam has no transactional integrity anyway). 
 For those cases, we tell them to add rollback_on_return=False to their 
create_engine to turn the behavior off.

But also maybe consider why you have a high volume of checkins, rather then 
working in some kind of transaction-per-logical-operation scheme (like a web 
request).


 
 Regards
 Tarek
 
 -- 
 Tarek Ziadé | http://ziade.org
 
 -- 
 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+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] rollbacks on select

2010-08-23 Thread Tarek Ziadé
On Mon, Aug 23, 2010 at 5:48 PM, Michael Bayer mike...@zzzcomputing.com wrote:


 Sent from my iPhone

 On Aug 23, 2010, at 8:29 PM, Tarek Ziadé ziade.ta...@gmail.com wrote:

 Hello,

 I use the default options to run queries via sql expressions and I've
 noticed that SQLAlchemy does a rollback
 after every select using the mysql default engine. These rollback are
 not really useful and eat 15% of the CPU time.

 Is this a normal behavior, part of the auto commit custom strategy
 SQLAlchemy implements ?

 If yes, is there a way to avoid those extra rollbacks ?

 Because we're using a connection pool, putting the connection back into the 
 pool without a rollback means you throw existing transactional locks and 
 state into the pool as well, holding them open indefinitely and generally 
 causing problems for subsequent usages of those pooled connections.

 However, we get a complaint about every 6 months from a mysql myisam user, 
 who uses many ad-hoc connection checkouts (which in itself is a little 
 unusual) and who would rather not have it (as myisam has no transactional 
 integrity anyway).  For those cases, we tell them to add 
 rollback_on_return=False to their create_engine to turn the behavior off.

 But also maybe consider why you have a high volume of checkins, rather then 
 working in some kind of transaction-per-logical-operation scheme (like a web 
 request).


Thanks Michael !

-- 
Tarek Ziadé | http://ziade.org

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] rollbacks on select

2010-08-23 Thread Tarek Ziadé
On Mon, Aug 23, 2010 at 5:53 PM, Tarek Ziadé ziade.ta...@gmail.com wrote:
 On Mon, Aug 23, 2010 at 5:48 PM, Michael Bayer mike...@zzzcomputing.com 
 wrote:


 Sent from my iPhone

 On Aug 23, 2010, at 8:29 PM, Tarek Ziadé ziade.ta...@gmail.com wrote:

 Hello,

 I use the default options to run queries via sql expressions and I've
 noticed that SQLAlchemy does a rollback
 after every select using the mysql default engine. These rollback are
 not really useful and eat 15% of the CPU time.

 Is this a normal behavior, part of the auto commit custom strategy
 SQLAlchemy implements ?

 If yes, is there a way to avoid those extra rollbacks ?

 Because we're using a connection pool, putting the connection back into the 
 pool without a rollback means you throw existing transactional locks and 
 state into the pool as well, holding them open indefinitely and generally 
 causing problems for subsequent usages of those pooled connections.

 However, we get a complaint about every 6 months from a mysql myisam user, 
 who uses many ad-hoc connection checkouts (which in itself is a little 
 unusual) and who would rather not have it (as myisam has no transactional 
 integrity anyway).  For those cases, we tell them to add 
 rollback_on_return=False to their create_engine to turn the behavior off.

 But also maybe consider why you have a high volume of checkins, rather then 
 working in some kind of transaction-per-logical-operation scheme (like a web 
 request).


 Thanks Michael !

Just for the record for others, the option is reset_on_return

Cheers
Tarek

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.