[sqlalchemy] sqlalchemy.exceptions.SQLError: (OperationalError) database is locked
I posted this message in the pylons group but as of yet have received no response. http://groups.google.com/group/pylons-discuss/browse_frm/thread/093ec04b48e49c3c?hl=en# I've been looking into this problem a little more. From my reading of the SQLite documentation there should be a 5 second timeout by default (I'm using pysqlite 2.3.2). Looking at the source this looks correct. However, in testing my app when I get this exception there is definitely no 5 second timeout! It happens immediately. I also tried 500 seconds, and had no better luck. When I concurrently access my webapp I immediately get this exception. Also the exception confuses me. The 'database is locked' text indicates that the error is SQLITE_LOCKED which is documented as: SQLITE_LOCKED This return code is similar to SQLITE_BUSY in that it indicates that the database is locked. But the source of the lock is a recursive call to sqlite_exec. This return can only occur if you attempt to invoke sqlite_exec from within a callback routine of a query from a prior invocation of sqlite_exec. Recursive calls to sqlite_exec are allowed as long as they do not attempt to write the same table. However, the documentation indicates that I should be getting SQLITE_BUSY or IOERROR. Anyone have any ideas how to solve this problem? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Add arbitrary information to some classes
That sounds reasonable to me; my knee-jerk thought was that we might need to worry about memory usage, but these references are only on low-count instances like tables, columns, sessions and mappers, not ORM object instances. On 10/31/07, Paul Johnston [EMAIL PROTECTED] wrote: Hi, Ah sure, so it's to be a namespace for namespaces, a shared dict() parking lot. Got it. How about having two dicts? One is purely for user data, libraries and such never touch it. I suggest userdata. The other is for use in extensions and stuff, say extdata. Paul --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: sqlalchemy.exceptions.SQLError: (OperationalError) database is locked
1st step would be to ensure youre on the latest version of sqlite. second step would be to create a test program illustrating the behavior using pysqlite only (sqlalchemy doesn't have anything to do with sqlite lock timeout issues). if you can confirm that the timeout isnt working in that case, you can submit a bug report to pysqlite and/or sqlite. the sqlite devs are *very* responsive to issues. On Nov 1, 2007, at 10:13 AM, Matthew Newhook wrote: I posted this message in the pylons group but as of yet have received no response. http://groups.google.com/group/pylons-discuss/browse_frm/thread/ 093ec04b48e49c3c?hl=en# I've been looking into this problem a little more. From my reading of the SQLite documentation there should be a 5 second timeout by default (I'm using pysqlite 2.3.2). Looking at the source this looks correct. However, in testing my app when I get this exception there is definitely no 5 second timeout! It happens immediately. I also tried 500 seconds, and had no better luck. When I concurrently access my webapp I immediately get this exception. Also the exception confuses me. The 'database is locked' text indicates that the error is SQLITE_LOCKED which is documented as: SQLITE_LOCKED This return code is similar to SQLITE_BUSY in that it indicates that the database is locked. But the source of the lock is a recursive call to sqlite_exec. This return can only occur if you attempt to invoke sqlite_exec from within a callback routine of a query from a prior invocation of sqlite_exec. Recursive calls to sqlite_exec are allowed as long as they do not attempt to write the same table. However, the documentation indicates that I should be getting SQLITE_BUSY or IOERROR. Anyone have any ideas how to solve this problem? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Add arbitrary information to some classes
sorry, i havent been following. two++ dicts ?! this is getting out of hand. if we have to have any dicts at all, it would be just one dict. and also, it should be proxied through a property so that if you dont access it, its never even created. we have this on ConnectionFairy right now and its called properties. I'd vote for some extremely neutral word like attr, and we put it on Table/ Column/ConnectionFairy, and we're done. i think the total usage for these dicts is very lowif we are concerned about extensions colliding with user data in these dicts, then we'd also be concerned about extensions colliding with other extensions, and mutliple dicts arent helping in that case anyway. keys can be placed as tuples (such as ('myext', 'somekey')) if namespace collisions are a concern, but that kind of thing has to be done by conventions regardless. On Nov 1, 2007, at 10:40 AM, Rick Morrison wrote: That sounds reasonable to me; my knee-jerk thought was that we might need to worry about memory usage, but these references are only on low-count instances like tables, columns, sessions and mappers, not ORM object instances. On 10/31/07, Paul Johnston [EMAIL PROTECTED] wrote: Hi, Ah sure, so it's to be a namespace for namespaces, a shared dict() parking lot. Got it. How about having two dicts? One is purely for user data, libraries and such never touch it. I suggest userdata. The other is for use in extensions and stuff, say extdata. Paul --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] assign_mapper and order_by?
Hello, Does assign_mapper have any order_by function available to him after the object has been mapped? model.py - myclass_table = sqlalchemy.Table('myClass', metadata, autoload=True) class myClass(object): pass myclassmapper=assign_mapper(session.context,myClass,myclass_table) controller.py-- Now in controller, at one point I am trying to order by Date x=model.myClass.select((model.myClass.c.STATE=='IL') I cannot do: x=model.myClass.select((model.myClass.c.STATE=='IL').order_by(model.myClass.DATE, DESC) ?? Is there another function that can do it? At this point the only way is to sort the list of results is to do it manually or use sqlalchemy.select() ? Is that correct? Thanks, Lucas --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] rlike with assign_mapper?
Others gave some pointers a while back on using rlike with query filters. I'm wondering whether there is some way to get rlike with assign_mapper syntax? I'm using right now Resource.select_by( **query_dict ) where query dict is name/val pairs, I'd like to be able to make those name/val pairs be re matches. Any tips most appreciated! Thanks Iain --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: adding an object through association_proxy
I think I misunderstood the use of the association proxy -- I don't think I want to use it in this case anymore... thx m On Oct 31, 6:33 pm, Matt [EMAIL PROTECTED] wrote: Hi all, I have a table (Content) which relates to itself via a many-to-many relationship through a link table (ContentCollection). I'm trying to setup parent/child relationships for the Content table using the association_proxy since there are some fields I'll need to modify in ContentCollection: class Content(object): children = association_proxy('collection_children', 'child') parents = association_proxy('parent_collections', 'parent') class ContentCollection(object): pass Session.mapper(Content, content,properties={ 'collection_children' : relation(ContentCollection, primaryjoin=content.c.id==content_collection.c.collection_id, cascade=all, delete, delete-orphan), 'parent_collections' : relation(ContentCollection, primaryjoin=content.c.id==content_collection.c.content_id, cascade=all, delete, delete-orphan) }) Session.mapper(ContentCollection, content_collection, properties={ 'child' : relation(Content, primaryjoin=content.c.id==content_collection.c.content_id), 'parent' : relation(Content, primaryjoin=content.c.id==content_collection.c.collection_id), }) Read access seems to work as I'd expect, but when I add an item using Content.children.append(item), I get something like: sqlalchemy.exceptions.OperationalError: (OperationalError) (1048, Column 'content_id' cannot be null) u'INSERT INTO content_collection (priority, home, version, creation_time, modification_time, collection_id, content_id, is_primary) VALUES (%s, %s, %s, UTC_TIMESTAMP(), UTC_TIMESTAMP(), %s, %s, %s)' [0, None, None, 79940L, None, None] Seems to only be supplying the id for the child and not the parent when it's creating the intermediate table record... Any ideas what I'm doing wrong here? thx Matt --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: rlike with assign_mapper?
To do this nicely ticket #767 would have to be fixed, but until then this should work: def rlike_match_all(entity, **kwargs): return and_(*[getattr(entity, key).comparator.expression_element().op('rlike')(value) for key,value in kwargs.items()]) and use it by Resource.select(rlike_match_all(Resource, query_dict)) Ants So you can On Nov 1, 8:12 pm, iain duncan [EMAIL PROTECTED] wrote: Others gave some pointers a while back on using rlike with query filters. I'm wondering whether there is some way to get rlike with assign_mapper syntax? I'm using right now Resource.select_by( **query_dict ) where query dict is name/val pairs, I'd like to be able to make those name/val pairs be re matches. Any tips most appreciated! Thanks Iain --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: rlike with assign_mapper?
for now, Resource.query.filter(resource_table.c.somecol.op('rlike') (value)) will work. On Nov 1, 2007, at 2:12 PM, iain duncan wrote: Others gave some pointers a while back on using rlike with query filters. I'm wondering whether there is some way to get rlike with assign_mapper syntax? I'm using right now Resource.select_by( **query_dict ) where query dict is name/val pairs, I'd like to be able to make those name/val pairs be re matches. Any tips most appreciated! Thanks Iain --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Foreign key error
I have two tables Incident and Entry with a 1:many relationship. Incident.orr_id is a primary key. Entry.entry_id is a primary key, and Entry.orr_id is a foreign key. (The column names are a legacy tradition.) I have the following model and classes: t_incident = Table(Incident, meta, autoload=True, autoload_with=engine) t_entry = Table(Entry, meta, Column('orr_id', types.Integer, ForeignKey(t_incident.c.orr_id)), autoload=True, autoload_with=engine) class Incident(object): pass class Entry(object): @classmethod def get(class_, entry_id): return Session.query(class_).get(entry_id) mapper(Entry, t_entry) mapper(Incident, t_incident, properties={ 'entries': relation(Entry, backref=incident), }) If I run x = Entry.get(519010), I get an exception: class 'sqlalchemy.exceptions.ArgumentError': Error determining primary and/or secondary join for relationship 'Incident.entries (Entry)'. If the underlying error cannot be corrected, you should specify the 'primaryjoin' (and 'secondaryjoin', if there is an association table present) keyword arguments to the relation() function (or for backrefs, by specifying the backref using the backref() function with keyword arguments) to explicitly specify the join conditions. Nested error is Can't find any foreign key relationships between 'Incident' and 'Entry' However, if I run the same statement again, it works. x = Entry.get(519010) x.entry_id 519010L x.orr_id = 7704L x.incident type 'exceptions.AttributeError': 'Entry' object has no attribute 'incident' Oops, the backref doesn't work. I was also getting an AttributeError on the 'get' method earlier, though that may have cleared up. But when I list all the columns rather than autoloading, the problems seem to go away. (Knock on wood.) -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Re: Foreign key error
On Nov 1, 2007, at 6:41 PM, Mike Orr wrote: I have two tables Incident and Entry with a 1:many relationship. Incident.orr_id is a primary key. Entry.entry_id is a primary key, and Entry.orr_id is a foreign key. (The column names are a legacy tradition.) I have the following model and classes: t_incident = Table(Incident, meta, autoload=True, autoload_with=engine) t_entry = Table(Entry, meta, Column('orr_id', types.Integer, ForeignKey(t_incident.c.orr_id)), autoload=True, autoload_with=engine) what happens if you autoload like the above, and then just say t_incident.join(t_entry) ? it likely breaks. then, what happens if you define t_entry before t_incident ? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[sqlalchemy] Strange deferred loading behavior...
I am quite baffled by the deferred loading behavior on a class member in the following code (see below). Looks like if I create an object (t1) with some field (c2) having None as value, then after I save, commit, and closed the object in a SQLAlchemy session, I cannot update the c2 field. It will give me an InvalidRequestError error. However, if I loaded the same object (into t2) from DB (even though t2.c2 field and attribute still having None as value), I can modify t2.c2 field even after I commit, and close the session that associated with t2. So, is this very confusing, or did I miss some of the reasons in this behavior? Ben sqlalchemy.exceptions.InvalidRequestError: Parent instance class '__main__.Test' is not bound to a Session; deferred load operation of attribute 'c2' cannot proceed class Test(Cachable): def __init__(self, c1, c2=None): self.c1 = c1 self.c2 = c2 engine = create_engine(url, echo=True) meta = MetaData() meta.bind = engine SessionMaker = sessionmaker(bind=engine, autoflush=True, transactional=True) table = Table('t_Test', meta, autoload=True) mapper(Test, table, order_by=None) t1 = Test(1) session = SessionMaker() session.save(t1) session.commit() session.close() #t1.c2 = 10 # this will cause InvalidRequestError session = SessionMaker() t2 = session.query(Test).filter_by(c1 = 1).one() session.commit() session.close() t2.c2 = 10 # However, this will NOT cause InvalidRequestError --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---