[sqlalchemy] Re: SQLAlchemy 0.4 MERGED TO TRUNK

2007-07-31 Thread Jorge Godoy
Marco Mariani wrote: > > Michael Bayer ha scritto: >> can i have an example >> > > http://trac.turbogears.org/browser/branches/1.0/turbogears/database.py?rev=2320 > > 281 [run_with_transaction.when("_use_sa()")] > 282 def sa_rwt(func, *args, **kw): > 283 log.debug("New SA tr

[sqlalchemy] Re: Default value for objects' attributes

2007-07-31 Thread Michael Bayer
On Jul 31, 2007, at 11:30 AM, Paul Johnston wrote: > > Hi, > >>> Seems like a good time to bring up a slightly related problem. If >>> you >>> modify an object in a function providing a default value, the >>> object is not flushed (unless you do that manually). >>> >> not sure i understand the

[sqlalchemy] Re: How to add to database a previously deleted object

2007-07-31 Thread Wojciech Smigaj
On Jul 31, 4:50 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Jul 31, 2007, at 7:14 AM, Wojciech Smigaj wrote: > > > I get the following error: > > > Traceback (most recent call last): > > File "test_case.py", line 34, in ? > > session.merge(obj) > > File "/usr/lib/python2.4/site-packa

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
Yeah this is what I did and it works. Was curious to know where the problem was. I guess I need to run through the code. Thanks Michael and all others! On 7/31/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > On Jul 31, 2007, at 10:48 AM, Arun Kumar PG wrote: > > > As mentioned in my earlier e

[sqlalchemy] Re: Default value for objects' attributes

2007-07-31 Thread Paul Johnston
Hi, >>Seems like a good time to bring up a slightly related problem. If you >>modify an object in a function providing a default value, the >>object is not flushed (unless you do that manually). >> >not sure i understand the scenario here, could you illustrate ? > > I've put a bit more expla

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Michael Bayer
On Jul 31, 2007, at 10:48 AM, Arun Kumar PG wrote: > As mentioned in my earlier email thread: > > I am using pool.QueuePool for managing connections and this pool is > fed with a creator function which returns an instance of my own > custom DBAPI class (I need this because of some logging st

[sqlalchemy] Re: How to add to database a previously deleted object

2007-07-31 Thread Michael Bayer
On Jul 31, 2007, at 7:14 AM, Wojciech Smigaj wrote: > I get the following error: > > Traceback (most recent call last): > File "test_case.py", line 34, in ? > session.merge(obj) > File "/usr/lib/python2.4/site-packages/SQLAlchemy-0.3.10-py2.4.egg/ > sqlalchemy/orm/session.py", line 501,

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
As mentioned in my earlier email thread: I am using pool.QueuePool for managing connections and this pool is fed with a creator function which returns an instance of my own custom DBAPI class (I need this because of some logging stuff that I am doing). This custom DBAPI class returns a Connection

[sqlalchemy] Re: SQLAlchemy 0.4 MERGED TO TRUNK

2007-07-31 Thread Marco Mariani
Michael Bayer ha scritto: > can i have an example > http://trac.turbogears.org/browser/branches/1.0/turbogears/database.py?rev=2320 281 [run_with_transaction.when("_use_sa()")] 282 def sa_rwt(func, *args, **kw): 283 log.debug("New SA transaction") 284 transaction = ses

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Michael Bayer
On Jul 31, 2007, at 3:40 AM, Arun Kumar PG wrote: > Looks like the problem is coming because of the fact when we are > updating a row in table with the same data the rowcount returned by > mysql is 0. Only when there is a change in data the rowcount is > returned. > > Assuming RollValue co

[sqlalchemy] Re: Default value for objects' attributes

2007-07-31 Thread Michael Bayer
On Jul 30, 2007, at 7:29 PM, Paul Johnston wrote: > > Hi, > >> The problem is that creating a new object from class Test doesn't set >> the default value for attributes : >> >> > Seems like a good time to bring up a slightly related problem. If you > modify an object in a function providing a de

[sqlalchemy] Re: get/get_by exceptions

2007-07-31 Thread Michael Bayer
On Jul 30, 2007, at 6:48 PM, Jonathon Anderson wrote: > > I realize that it is probably much too late in the game for this, > but... > > I've always thought that returning None for get/get_by when no record > exists is less explicit than raising an exception. I really like > Django's idiom of ha

[sqlalchemy] Re: SQLAlchemy 0.4 MERGED TO TRUNK

2007-07-31 Thread Michael Bayer
can i have an example On Jul 30, 2007, at 5:51 PM, Jorge Godoy wrote: > > Michael Bayer wrote: > >> a lot. no decorators for now. > > Not even the way we did on TurboGears that mimics the PEAK > decorators? This > way, people can use "@decorator(param)" on Python 2.4+ and can > use "[decorat

[sqlalchemy] Re: multiple mapper extensions

2007-07-31 Thread Michael Bayer
On Jul 30, 2007, at 4:58 PM, Jonathan LaCour wrote: > > Michael Bayer wrote: > >> its a model taken from the way event loops usually work; any consumer >> along the event chain is allowed to say, "ive consumed the event" and >> stop further handlers from dealing with it. we can certainly change

[sqlalchemy] Re: Session Problem

2007-07-31 Thread robertz23
Thanks Michael and Paul, you're are both right. I fixed my problem thanks to you. I think it's better if somebody include this patch in future versions. Thanks again, Roberto Zapata On Jul 30, 7:27 pm, Paul Johnston <[EMAIL PROTECTED]> wrote: > Hi, > > This is TurboGears ticket #1419http

[sqlalchemy] How to add to database a previously deleted object

2007-07-31 Thread Wojciech Smigaj
Hi, I have the following question: if an object has been deleted from a database using session.delete(), which method of the Session object should be used to add that object back to the database? I thought merge() should do the trick, but it doesn't work. For example, when I invoke the following

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
Passing client_flag = 2 to the MySQLDb.connect solves the problem but again I am confused why this was working with the earlier version. Looks like 3.9version has an update which makes the code that does not specifies client_flag fail ? On 7/31/07, King Simon-NFHD78 <[EMAIL PROTECTED]> wrote:

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread King Simon-NFHD78
databases/mysql.py has this snippet in create_connect_args (0.3.10): # FOUND_ROWS must be set in CLIENT_FLAGS for to enable # supports_sane_rowcount. client_flag = opts.get('client_flag', 0) if self.dbapi is not None: try: import MySQLdb

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
The MySQLdb library has CLIENT.FOUND_ROWS = 2. What value ideally it should have ? I am still now clear why this problem was not coming in the earlier SA version! On 7/31/07, Arun Kumar PG <[EMAIL PROTECTED]> wrote: > > I am using pool.QueuePool for managing connections and this pool is fed > wit

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
I am using pool.QueuePool for managing connections and this pool is fed with a creator function which returns an instance of my own custom DBAPI class (I need this because of some logging stuff that I am doing). This custom DBAPI class returns a Connection object returned by MySQLdb.connect. >>> T

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread jason kirtland
Arun Kumar PG wrote: > Looks like the problem is coming because of the fact when we are > updating a row in table with the same data the rowcount returned by > mysql is 0. Only when there is a change in data the rowcount is returned. Are you creating connections outside of SQLAlchemy? (I seem

[sqlalchemy] Re: get/get_by exceptions

2007-07-31 Thread Jonathan Ballet
On 31 juil, 00:48, Jonathon Anderson <[EMAIL PROTECTED]> wrote: > With sqlalchemy, I find myself always spelling: > > instance = Entity.get(instance_id) > if not instance: > print "no record of an instance with id %s" % instance_id > else: > print instance There's a load() method, an

[sqlalchemy] Re: Default value for objects' attributes

2007-07-31 Thread Jonathan Ballet
On 30 juil, 22:33, Michael Bayer <[EMAIL PROTECTED]> wrote: > yes, figured that. The issues with this are that it would not be > consistently available; it could only work for Python-side defaults, > and could also only work for defaults that do not require an > ExecutionContext Ah, consistency,

[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1

2007-07-31 Thread Arun Kumar PG
Looks like the problem is coming because of the fact when we are updating a row in table with the same data the rowcount returned by mysql is 0. Only when there is a change in data the rowcount is returned. Assuming RollValue column is changing from 99 to 100 if I execute the following statements: