oh, nice. upgrading sqlite to 3.3.7 and rebuilding pysqlite2 fixed it -- sorry for the noise.
On 1/12/07, Kumar McMillan <[EMAIL PROTECTED]> wrote: > uggh, pysqlite 2.1 fixed some other problems I was having in > transactions iirc. I'm scared to upgrade/downgrade :( > > On 1/11/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > > > the important thing is your sqlite version. im on 3.2.1. my > > pysqlite seems to be....2.0.2 ? maybe a new pysqlite bug, not sure. > > also the sql echo shows that something is weird...its inserting a > > row, then deleting it, using id 1, which is what the id should be. > > the "rowcount" should definitely be "1" and not "0". > > > > > > On Jan 11, 2007, at 8:30 PM, Kumar McMillan wrote: > > > > > > > > hi. the reason for the flush strangeness is I grabbed these > > > statements from separate areas of the app to reproduce the scenario > > > (but I guess the app needs cleanup, heh). > > > > > > What version of pysqilte did you test with? Mine is pysqlite 2.3.2 on > > > python 2.4.3, sqlalchemy dev r 2183; maybe that's all it is (memory > > > weirdness). > > > > > > below is my sql, output, etc, showing the same test failing for me. > > > > > > I see what you mean about the sqlite instances. Actually when I run > > > it w/ the 2nd call as a connection to postgres, there are no errors. > > > Since that is a better representation of my real problem I'm not so > > > worried about the failure anymore. And currently I'm working around > > > it all using two separate BoundMetaData which is OK to me. But I'm > > > still curious as to what could be wrong with my setup. > > > > > > _ > > > > > > 2007-01-11 19:16:55,779 INFO sqlalchemy.engine.base.Engine.0x..30 > > > PRAGMA table_info(offers) > > > 2007-01-11 19:16:55,779 INFO sqlalchemy.engine.base.Engine.0x..30 {} > > > 2007-01-11 19:16:55,781 INFO sqlalchemy.engine.base.Engine.0x..30 > > > CREATE TABLE offers ( > > > id INTEGER NOT NULL, > > > name TEXT, > > > PRIMARY KEY (id) > > > ) > > > > > > > > > 2007-01-11 19:16:55,781 INFO sqlalchemy.engine.base.Engine.0x..30 None > > > 2007-01-11 19:16:55,782 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,784 INFO sqlalchemy.engine.base.Engine.0x..30 > > > BEGIN > > > 2007-01-11 19:16:55,786 INFO sqlalchemy.engine.base.Engine.0x..30 > > > INSERT INTO offers (name) VALUES (?) > > > 2007-01-11 19:16:55,786 INFO sqlalchemy.engine.base.Engine.0x..30 > > > ['foobar'] > > > 2007-01-11 19:16:55,787 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,790 INFO sqlalchemy.engine.base.Engine.0x..30 > > > SELECT offers.id AS offers_id, offers.name AS offers_name > > > FROM offers ORDER BY offers.oid > > > 2007-01-11 19:16:55,790 INFO sqlalchemy.engine.base.Engine.0x..30 [] > > > 2007-01-11 19:16:55,791 INFO sqlalchemy.engine.base.Engine.0x..30 > > > BEGIN > > > 2007-01-11 19:16:55,792 INFO sqlalchemy.engine.base.Engine.0x..30 > > > DELETE FROM offers WHERE offers.id = ? > > > 2007-01-11 19:16:55,793 INFO sqlalchemy.engine.base.Engine.0x..30 [1] > > > 2007-01-11 19:16:55,793 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,794 INFO sqlalchemy.engine.base.Engine.0x..30 > > > SELECT offers.id AS offers_id, offers.name AS offers_name > > > FROM offers ORDER BY offers.oid > > > 2007-01-11 19:16:55,795 INFO sqlalchemy.engine.base.Engine.0x..30 [] > > > 2007-01-11 19:16:55,796 INFO sqlalchemy.engine.base.Engine.0x..30 > > > PRAGMA table_info(offers) > > > 2007-01-11 19:16:55,796 INFO sqlalchemy.engine.base.Engine.0x..30 {} > > > 2007-01-11 19:16:55,796 INFO sqlalchemy.engine.base.Engine.0x..30 > > > DROP TABLE offers > > > 2007-01-11 19:16:55,797 INFO sqlalchemy.engine.base.Engine.0x..30 None > > > 2007-01-11 19:16:55,797 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,799 INFO sqlalchemy.engine.base.Engine.0x..30 > > > PRAGMA table_info(offers) > > > 2007-01-11 19:16:55,799 INFO sqlalchemy.engine.base.Engine.0x..30 {} > > > 2007-01-11 19:16:55,800 INFO sqlalchemy.engine.base.Engine.0x..30 > > > CREATE TABLE offers ( > > > id INTEGER NOT NULL, > > > name TEXT, > > > PRIMARY KEY (id) > > > ) > > > > > > > > > 2007-01-11 19:16:55,800 INFO sqlalchemy.engine.base.Engine.0x..30 None > > > 2007-01-11 19:16:55,800 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,802 INFO sqlalchemy.engine.base.Engine.0x..30 > > > BEGIN > > > 2007-01-11 19:16:55,803 INFO sqlalchemy.engine.base.Engine.0x..30 > > > INSERT INTO offers (name) VALUES (?) > > > 2007-01-11 19:16:55,803 INFO sqlalchemy.engine.base.Engine.0x..30 > > > ['foobar'] > > > 2007-01-11 19:16:55,804 INFO sqlalchemy.engine.base.Engine.0x..30 > > > COMMIT > > > 2007-01-11 19:16:55,805 INFO sqlalchemy.engine.base.Engine.0x..30 > > > SELECT offers.id AS offers_id, offers.name AS offers_name > > > FROM offers ORDER BY offers.oid > > > 2007-01-11 19:16:55,805 INFO sqlalchemy.engine.base.Engine.0x..30 [] > > > 2007-01-11 19:16:55,806 INFO sqlalchemy.engine.base.Engine.0x..30 > > > BEGIN > > > 2007-01-11 19:16:55,807 INFO sqlalchemy.engine.base.Engine.0x..30 > > > DELETE FROM offers WHERE offers.id = ? > > > 2007-01-11 19:16:55,807 INFO sqlalchemy.engine.base.Engine.0x..30 [1] > > > 2007-01-11 19:16:55,808 INFO sqlalchemy.engine.base.Engine.0x..30 > > > ROLLBACK > > > Traceback (most recent call last): > > > File "test_sa_concurrent.py", line 56, in ? > > > db_roundtrip('sqlite:///:memory:') > > > File "test_sa_concurrent.py", line 42, in db_roundtrip > > > session.flush() > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/session.py", > > > line 220, in flush > > > self.uow.flush(self, objects) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 194, in flush > > > flush_context.execute() > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 333, in execute > > > head.execute(self) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 470, in execute > > > UOWExecutor().execute(trans, self) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 795, in execute > > > self.execute_delete_steps(trans, task) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 824, in execute_delete_steps > > > self.delete_objects(trans, task) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 801, in delete_objects > > > task._delete_objects(trans) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/unitofwork.py", > > > line 464, in _delete_objects > > > task.mapper.delete_obj(task.todelete_objects, trans) > > > File "/Users/kumar/src/sqlalchemy/lib/sqlalchemy/orm/mapper.py", > > > line 1070, in delete_obj > > > raise exceptions.ConcurrentModificationError("Updated rowcount %d > > > does not match number of objects updated %d" % (c.cursor.rowcount, > > > len(delete)))sqlalchemy.exceptions.ConcurrentModificationError: > > > Updated rowcount 0 does not match number of objects updated 1 > > > > > > > > > On 1/6/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > > >> > > >> when i run this program, I get no errors. > > >> > > >> a few things to note: > > >> > > >> it makes no sense to do a session.flush() after youve dropped the > > >> table (similarly, it makes no sense to flush() before youve done > > >> anything but thats less of an issue). if there were any modified > > >> state within your session to actually be flushed, the operation would > > >> fail since the table is dropped (but in this test, theres no changes > > >> to flush at that point, so no error occurs). > > >> > > >> running the same test twice with two separate instances of "sqlite:// > > >> memory" will produce no continuity between the two databases, since > > >> sqlite://memory databases are completely unique per connection. but > > >> again, in this test youre doing a completely new and unrelated set of > > >> operations on each connection, so no error occurs. > > >> > > >> wild guess, that the test you have which fails is switching between > > >> "sqlite://memory" databases within a single ORM session, so the > > >> update of a row saved within the first sqlite://memory database > > >> produces no changes within the second sqlite://memory database since > > >> its a completely new database (but then, youd also have to get the > > >> table creates in there too, so still not exactly sure what the > > >> conditions are on your end). > > >> > > >> in any case, viewing SQL output should reveal exactly whats going on. > > >> > > >> > > >> On Jan 6, 2007, at 6:54 PM, Kumar McMillan wrote: > > >> > > >>> hello. > > >>> > > >>> I'm trying to use DynamicMetaData so that two separate tests can > > >>> each > > >>> connect to a unique db, create some tables, insert some data, delete > > >>> that data, then drop the tables. > > >>> > > >>> This seems to yield ... > > >>> > > >>> sqlalchemy.exceptions.ConcurrentModificationError: Updated > > >>> rowcount 0 > > >>> does not match number of objects updated 1 > > >>> > > >>> ... the second time around, when trying to delete the data. I > > >>> checked > > >>> the list and FAQ and note that I am *not* trying to modify a primary > > >>> key. This seems related to the use of DynamicMetaData and the fact > > >>> that I am creating the table then dropping it. > > >>> > > >>> I was able to reproduce this scenario in a single test (below and > > >>> attached) so maybe you can see something simple I'm doing wrong? > > >>> Experimenting, I noticed that if I use two separate BoundMetaData > > >>> instances *or* switch to checkfirst=True and not drop the table then > > >>> the test works fine. However, I don't see why this shouldn't be > > >>> possible with DynamicMetaData. Thanks in advance. > > >>> > > >>> PS. this was in sqlalchemy trunk r 2183 > > >>> > > >>> _ > > >>> > > >>> import sqlalchemy > > >>> from sqlalchemy import * > > >>> from sqlalchemy.ext.assignmapper import assign_mapper > > >>> from sqlalchemy.ext.sessioncontext import SessionContext > > >>> def eq_(a,b): > > >>> assert a==b, "%s != %s" % (a,b) > > >>> > > >>> meta = DynamicMetaData() > > >>> > > >>> offers = Table("offers", meta, > > >>> Column("id", INT, primary_key=True), > > >>> Column("name", String ), > > >>> ) > > >>> class Offer(object): > > >>> pass > > >>> > > >>> def db_roundtrip(dsn): > > >>> conn = meta.connect(dsn) > > >>> meta.engine.echo = 1 > > >>> > > >>> context = SessionContext( > > >>> lambda: sqlalchemy.create_session(bind_to=meta.engine)) > > >>> assign_mapper(context, Offer, offers) > > >>> session = context.current > > >>> > > >>> meta.create_all() > > >>> session.flush() > > >>> > > >>> offer = Offer() > > >>> offer.name = 'foobar' > > >>> session.save(offer) > > >>> session.flush() > > >>> > > >>> rows = Offer.select() > > >>> eq_(len(rows), 1) > > >>> eq_(rows[0].id, 1) > > >>> eq_(rows[0].name, 'foobar') > > >>> > > >>> session.delete(offer) > > >>> session.flush() > > >>> > > >>> rows = Offer.select() > > >>> eq_(len(rows), 0) > > >>> > > >>> meta.drop_all() > > >>> session.flush() > > >>> > > >>> sqlalchemy.orm.clear_mappers() > > >>> > > >>> if __name__ == '__main__': > > >>> > > >>> db_roundtrip('sqlite:///:memory:') > > >>> # pretend this is another connection : > > >>> db_roundtrip('sqlite:///:memory:') > > >>> > > >>> print 'OK' > > >>> > > >>>> > > >>> <test_sa_concurrent.py> > > >> > > >> > > >>> > > >> > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---