[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1
Hi, Jose! Hello sa-team! I have the same question... did you got the solution? p.s. I use SA 0.6.1 i will post a test example if needed thanks in advance, Iskren On 19 Май, 10:32, jose soares jose.soa...@sferacarta.com wrote: Hi all, Someone knows what this error mean? ... File /home/ve/sfera/release/sicer/BASE/model/anagraficaAlta/unita_aziendale.py, line 154, in aggiorna_capi_bovini x.flush() File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/ext/assignmapper.py, line 20, in do return getattr(session, name)(self, *args, **kwargs) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/session.py, line 319, in flush self.uow.flush(self, objects) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 210, in flush flush_context.execute() File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 400, in execute UOWExecutor().execute(self, head) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1020, in execute self.execute_delete_steps(trans, task) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1043, in execute_delete_steps self.delete_objects(trans, task) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1026, in delete_objects task.mapper.delete_obj(task.polymorphic_todelete_objects, trans) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/mapper.py, line 1322, in delete_obj raise exceptions.ConcurrentModificationError(Updated rowcount %d does not match number of objects updated %d % (c.rowcount, len(delete))) -- 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 athttp://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.
[sqlalchemy] Re: ConcurrentModificationError: Updated rowcount 0 does not match number of objects updated 1
in 0.6.1 in my case it was because: 1) i create an instance, 2) save it 3) delete it 4) change it** 5) again save it if i skip 4) and go to 5 its OK or if use update as 5) instead of save() its again OK On 15 Юли, 17:06, Iskren Stanislavov thesunlo...@gmail.com wrote: Hi, Jose! Hello sa-team! I have the same question... did you got the solution? p.s. I use SA 0.6.1 i will post a test example if needed thanks in advance, Iskren On 19 Май, 10:32, jose soares jose.soa...@sferacarta.com wrote: Hi all, Someone knows what this error mean? ... File /home/ve/sfera/release/sicer/BASE/model/anagraficaAlta/unita_aziendale.py, line 154, in aggiorna_capi_bovini x.flush() File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/ext/assignmapper.py, line 20, in do return getattr(session, name)(self, *args, **kwargs) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/session.py, line 319, in flush self.uow.flush(self, objects) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 210, in flush flush_context.execute() File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 400, in execute UOWExecutor().execute(self, head) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1020, in execute self.execute_delete_steps(trans, task) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1043, in execute_delete_steps self.delete_objects(trans, task) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/unitofwork.py, line 1026, in delete_objects task.mapper.delete_obj(task.polymorphic_todelete_objects, trans) File /home/ve/lib/python2.5/site-packages/SQLAlchemy-0.3.10-py2.5.egg/sqlalchemy/orm/mapper.py, line 1322, in delete_obj raise exceptions.ConcurrentModificationError(Updated rowcount %d does not match number of objects updated %d % (c.rowcount, len(delete))) -- 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 athttp://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.
[sqlalchemy] SQLAlchemy 0.6.3 released
hello again ! Just a week and a half ago, we put out version 0.6.2. Wouldn't you know it, the very next day someone came along and reported an issue that wasn't hard to fix but I felt really, really had to go out. The issue was #1845, any dirty object in a flush that had a many-to-many relationship would unconditionally load the collection fully. Many-to-manys of course being subject to being very large collections in one direction quite often. Yikes ! My apologies to anyone who's been putting up with that since 0.6.0. So I'd recommend everyone using many-to-many relationships should upgrade. Another biggish issue was that the auto-reconnect support wasn't working as intended with MySQL. It was still working since MySQL-Python as well as OurSQL do a reconnect in any case. But now our own pool-dispose-recreate phase should be kicking in as it does with other platforms. A handful of other fixes got in too, quite a bit for just nine days. Download SQLAlchemy 0.6.3 at: http://www.sqlalchemy.org/download.html 0.6.3 = - orm - Removed errant many-to-many load in unitofwork which triggered unnecessarily on expired/unloaded collections. This load now takes place only if passive_updates is False and the parent primary key has changed, or if passive_deletes is False and a delete of the parent has occurred. [ticket:1845] - Column-entities (i.e. query(Foo.id)) copy their state more fully when queries are derived from themselves + a selectable (i.e. from_self(), union(), etc.), so that join() and such have the correct state to work from. [ticket:1853] - Fixed bug where Query.join() would fail if querying a non-ORM column then joining without an on clause when a FROM clause is already present, now raises a checked exception the same way it does when the clause is not present. [ticket:1853] - Improved the check for an unmapped class, including the case where the superclass is mapped but the subclass is not. Any attempts to access cls._sa_class_manager.mapper now raise UnmappedClassError(). [ticket:1142] - Added column_descriptions accessor to Query, returns a list of dictionaries containing naming/typing information about the entities the Query will return. Can be helpful for building GUIs on top of ORM queries. - mysql - The _extract_error_code() method now works correctly with each MySQL dialect ( MySQL-python, OurSQL, MySQL-Connector-Python, PyODBC). Previously, the reconnect logic would fail for OperationalError conditions, however since MySQLdb and OurSQL have their own reconnect feature, there was no symptom for these drivers here unless one watched the logs. [ticket:1848] - oracle - More tweaks to cx_oracle Decimal handling. Ambiguous numerics with no decimal place are coerced to int at the connection handler level. The advantage here is that ints come back as ints without SQLA type objects being involved and without needless conversion to Decimal first. Unfortunately, some exotic subquery cases can even see different types between individual result rows, so the Numeric handler, when instructed to return Decimal, can't take full advantage of native decimal mode and must run isinstance() on every value to check if its Decimal already. Reopen of [ticket:1840] -- 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] problem with multi-table mapping - how to configure merge/cascade behaviour on mappers based on join/select?
A new problem, which seems to occur in both IronPython and normal Python: I have a database with tables for movies, directors, genres (and a bridging table movie_directors) I have a class mapped to a join of all three of the above j = join(movies_table,md_table).join(directors_table).join(genres_table) mapper(MoviesAndDirectorsAndGenres,j.select(use_labels=True).alias('moviesdirectorsgenres')) this works fine. i can query the database ok using this mapper. The tables already have some values in. Now, I want to create a new composite object, that references some of the existing values, but not all - say it's a new movie by an existing director in an existing genre: new = MoviesAndDirectorsAndGenres() new.movies_movie_id=8 #does not already exist in the table new.directors_director_id=2 #already exists in the table new.genres_genre_id=6 #already exists too session.add(new) this fails with a constraint error / integrity error, because SQLA tries to re-insert genre #6 even though it already exists. it also happens if i use session.merge(new). it also happens if i fully specify all of the attributes of each movie/director/genre correctly. Is this expected behaviour? is there any way to get sqla to intelligently only do inserts when necessary? is it something to do with cascade configuration, and if so, how do i configure cascades on a mapper that's not based on relationship() but based on join()? thanks in advance! HP -- 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 run a stored procedure?
Hello, I need to get data out of sqlserver by running this stored procedure. From there I convert few fields and add the processed rows to a mysql table that I have created. How can I do the following in sqlalchemy? Is there a pythonic way? Assuming I already have the database connection? What would be the syntax to run a stroed procedure? And what object would the results be in? USE [Reports] GO DECLARE @return_value int EXEC@return_value = [dbo].[assp_Report_DailyTransactions] @start_date = N'07/01/2010', @end_date = N'07/15/2010' SELECT 'Return Value' = @return_value Thanks, Lucas -- 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 run a stored procedure?
take a look at: http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html?highlight=sql.func#sqlalchemy.sql.expression.func On 07/15/2010 12:29 PM, Lukasz Szybalski wrote: Hello, I need to get data out of sqlserver by running this stored procedure. From there I convert few fields and add the processed rows to a mysql table that I have created. How can I do the following in sqlalchemy? Is there a pythonic way? Assuming I already have the database connection? What would be the syntax to run a stroed procedure? And what object would the results be in? USE [Reports] GO DECLARE @return_value int EXEC@return_value = [dbo].[assp_Report_DailyTransactions] @start_date = N'07/01/2010', @end_date = N'07/15/2010' SELECT 'Return Value' = @return_value Thanks, Lucas -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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] problem with multi-table mapping - how to configure merge/cascade behaviour on mappers based on join/select?
On Jul 15, 2010, at 2:52 PM, Harry Percival wrote: A new problem, which seems to occur in both IronPython and normal Python: I have a database with tables for movies, directors, genres (and a bridging table movie_directors) I have a class mapped to a join of all three of the above j = join(movies_table,md_table).join(directors_table).join(genres_table) mapper(MoviesAndDirectorsAndGenres,j.select(use_labels=True).alias('moviesdirectorsgenres')) this works fine. i can query the database ok using this mapper. The tables already have some values in. Now, I want to create a new composite object, that references some of the existing values, but not all - say it's a new movie by an existing director in an existing genre: new = MoviesAndDirectorsAndGenres() new.movies_movie_id=8 #does not already exist in the table new.directors_director_id=2 #already exists in the table new.genres_genre_id=6 #already exists too session.add(new) this fails with a constraint error / integrity error, because SQLA tries to re-insert genre #6 even though it already exists. it also happens if i use session.merge(new). it also happens if i fully specify all of the attributes of each movie/director/genre correctly. Is this expected behaviour? is there any way to get sqla to intelligently only do inserts when necessary? is it something to do with cascade configuration, and if so, how do i configure cascades on a mapper that's not based on relationship() but based on join()? you should be using merge(), and you should ensure that the objects being merged have the correct primary key values. If genre #6 refers to some other column that isn't the primary key of that row, then you'd have to ensure you put the correct primary key value on your object first before merging it. you can always check what decision merge() made by asking, obj in session.new versus obj in session.dirty. -- 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] checking for C extensions at runtime
I was wondering if there was a way to check at runtime if the C extensions were built with SQLAlchemy? If not I was wondering if you would consider adding something to the __version__ string? -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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] Re: how to run a stored procedure?
On Jul 15, 2:39 pm, David Gardner dgard...@creatureshop.com wrote: take a look at:http://www.sqlalchemy.org/docs/reference/sqlalchemy/expressions.html?... Now, Could you give me an example of it ? I understand how to run func to get values like current timestamp, or countbut how to run a stored proc? print func.assp_Report_DailyTransactions(start_date='20100701',end_date='20100715') ?? Is this the format? or? Thanks, Lucas On 07/15/2010 12:29 PM, Lukasz Szybalski wrote: Hello, I need to get data out of sqlserver by running this stored procedure. From there I convert few fields and add the processed rows to a mysql table that I have created. How can I do the following in sqlalchemy? Is there a pythonic way? Assuming I already have the database connection? What would be the syntax to run a stroed procedure? And what object would the results be in? USE [Reports] GO DECLARE �...@return_value int EXEC @return_value = [dbo].[assp_Report_DailyTransactions] �...@start_date = N'07/01/2010', �...@end_date = N'07/15/2010' SELECT 'Return Value' = @return_value Thanks, Lucas -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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] checking for C extensions at runtime
On Jul 15, 2010, at 4:03 PM, David Gardner wrote: I was wondering if there was a way to check at runtime if the C extensions were built with SQLAlchemy? If not I was wondering if you would consider adding something to the __version__ string? is there some guideline for the format on that ? -- David Gardner Pipeline Tools Programmer Jim Henson Creature Shop dgard...@creatureshop.com -- 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] problem with multi-table mapping - how to configure merge/cascade behaviour on mappers based on join/select?
thanks Michael. I really appreciate your help. How should use .merge()? I've tried both: another_new = MoviesAndDirectorsAndGenres() #init another_new as blank row another_new = session.merge(new) #attempt to merge with my 'new' object that has desired attributes and new = session.merge(another_new) #attempt to merge blank object to my new object with desired attributes the former fails trying to add a genre row that already exists, the latter fails trying to add an object with all null values. the thing is, I'm really not trying to merge anything. I'm trying to create a new object, which happens to be made up partially of new entries in some tables, and existing entries in other tables. genres_genre_id refers to the primary key of the genres table, and a genre with genre_id=6 already exists. am i going to have to map an ORM class to each of the composite tables, and use references to them via relationship() instead of hoping sql can figure it out by itself from the tables that make up the join construct? can supply a sqlite database and some source code if it helps? rgds, Harry On Thu, Jul 15, 2010 at 9:48 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Jul 15, 2010, at 2:52 PM, Harry Percival wrote: A new problem, which seems to occur in both IronPython and normal Python: I have a database with tables for movies, directors, genres (and a bridging table movie_directors) I have a class mapped to a join of all three of the above j = join(movies_table,md_table).join(directors_table).join(genres_table) mapper(MoviesAndDirectorsAndGenres,j.select(use_labels=True).alias('moviesdirectorsgenres')) this works fine. i can query the database ok using this mapper. The tables already have some values in. Now, I want to create a new composite object, that references some of the existing values, but not all - say it's a new movie by an existing director in an existing genre: new = MoviesAndDirectorsAndGenres() new.movies_movie_id=8 #does not already exist in the table new.directors_director_id=2 #already exists in the table new.genres_genre_id=6 #already exists too session.add(new) this fails with a constraint error / integrity error, because SQLA tries to re-insert genre #6 even though it already exists. it also happens if i use session.merge(new). it also happens if i fully specify all of the attributes of each movie/director/genre correctly. Is this expected behaviour? is there any way to get sqla to intelligently only do inserts when necessary? is it something to do with cascade configuration, and if so, how do i configure cascades on a mapper that's not based on relationship() but based on join()? you should be using merge(), and you should ensure that the objects being merged have the correct primary key values. If genre #6 refers to some other column that isn't the primary key of that row, then you'd have to ensure you put the correct primary key value on your object first before merging it. you can always check what decision merge() made by asking, obj in session.new versus obj in session.dirty. -- 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. -- -- Harry J.W. Percival -- Italy Mobile: +39 389 095 8959 UK Mobile: +44 (0) 78877 02511 Skype: harry dot percival -- 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] Re: SQLAlchemy 0.6.3 released
Thanks for doing 1853 so quickly. On Jul 15, 5:57 pm, Michael Bayer mike...@zzzcomputing.com wrote: hello again ! Just a week and a half ago, we put out version 0.6.2. Wouldn't you know it, the very next day someone came along and reported an issue that wasn't hard to fix but I felt really, really had to go out. The issue was #1845, any dirty object in a flush that had a many-to-many relationship would unconditionally load the collection fully. Many-to-manys of course being subject to being very large collections in one direction quite often. Yikes ! My apologies to anyone who's been putting up with that since 0.6.0. So I'd recommend everyone using many-to-many relationships should upgrade. Another biggish issue was that the auto-reconnect support wasn't working as intended with MySQL. It was still working since MySQL-Python as well as OurSQL do a reconnect in any case. But now our own pool-dispose-recreate phase should be kicking in as it does with other platforms. A handful of other fixes got in too, quite a bit for just nine days. Download SQLAlchemy 0.6.3 at: http://www.sqlalchemy.org/download.html 0.6.3 = - orm - Removed errant many-to-many load in unitofwork which triggered unnecessarily on expired/unloaded collections. This load now takes place only if passive_updates is False and the parent primary key has changed, or if passive_deletes is False and a delete of the parent has occurred. [ticket:1845] - Column-entities (i.e. query(Foo.id)) copy their state more fully when queries are derived from themselves + a selectable (i.e. from_self(), union(), etc.), so that join() and such have the correct state to work from. [ticket:1853] - Fixed bug where Query.join() would fail if querying a non-ORM column then joining without an on clause when a FROM clause is already present, now raises a checked exception the same way it does when the clause is not present. [ticket:1853] - Improved the check for an unmapped class, including the case where the superclass is mapped but the subclass is not. Any attempts to access cls._sa_class_manager.mapper now raise UnmappedClassError(). [ticket:1142] - Added column_descriptions accessor to Query, returns a list of dictionaries containing naming/typing information about the entities the Query will return. Can be helpful for building GUIs on top of ORM queries. - mysql - The _extract_error_code() method now works correctly with each MySQL dialect ( MySQL-python, OurSQL, MySQL-Connector-Python, PyODBC). Previously, the reconnect logic would fail for OperationalError conditions, however since MySQLdb and OurSQL have their own reconnect feature, there was no symptom for these drivers here unless one watched the logs. [ticket:1848] - oracle - More tweaks to cx_oracle Decimal handling. Ambiguous numerics with no decimal place are coerced to int at the connection handler level. The advantage here is that ints come back as ints without SQLA type objects being involved and without needless conversion to Decimal first. Unfortunately, some exotic subquery cases can even see different types between individual result rows, so the Numeric handler, when instructed to return Decimal, can't take full advantage of native decimal mode and must run isinstance() on every value to check if its Decimal already. Reopen of [ticket:1840] -- 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.