Re: [sqlalchemy] add new row into a many_to_one relationship database via ORM

2015-07-17 Thread Mike Bayer
On 7/17/15 5:02 AM, Chengjun JIN wrote: Hi all, I am trying to add new rows into an existing many to one database via sqlalchemy ORM. What I am doing now(it seems working): # The many to one relationship is: stock = relationship('Stock', backref=backref('historicalprices', order_by=id))

[sqlalchemy] add new row into a many_to_one relationship database via ORM

2015-07-17 Thread Chengjun JIN
Hi all, I am trying to add new rows into an existing many to one database via sqlalchemy ORM. What I am doing now(it seems working): # The many to one relationship is: stock = relationship('Stock', backref=backref('historicalprices', order_by=id)) # query an object stock =

Re: [sqlalchemy] Columns not deferred when an object is merged into a session with load=False

2015-07-17 Thread Tom Flannaghan
Thanks a lot! This works well. Tom On Thu, 16 Jul 2015 at 21:23 Mike Bayer mike...@zzzcomputing.com wrote: On 7/16/15 2:28 PM, Tom Flannaghan wrote: Thanks for your reply. Our exact problem is that we are creating empty detached objects from the primary key alone, and then merging them

[sqlalchemy] Issue with dynamically loaded modules and SQLAlchemy

2015-07-17 Thread Jeffrey McLarty
Hello, I've got a very peculiar situation, where SQLA fails to create an engine, because it can't find the installed module, only when I do some relatively straightforward package discovery import logic using imp.find_module and imp.load_module. I'm wondering if SQLAlchemy does some magic

Re: [sqlalchemy] Issue with dynamically loaded modules and SQLAlchemy

2015-07-17 Thread Mike Bayer
On 7/17/15 1:39 PM, Mike Bayer wrote: On 7/17/15 1:21 PM, Jeffrey McLarty wrote: Hello, I've got a very peculiar situation, where SQLA fails to create an engine, because it can't find the installed module, only when I do some relatively straightforward package discovery import logic

Re: [sqlalchemy] Issue with dynamically loaded modules and SQLAlchemy

2015-07-17 Thread Mike Bayer
On 7/17/15 1:21 PM, Jeffrey McLarty wrote: Hello, I've got a very peculiar situation, where SQLA fails to create an engine, because it can't find the installed module, only when I do some relatively straightforward package discovery import logic using imp.find_module and imp.load_module.

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
On Friday, July 17, 2015 at 2:46:42 PM UTC-4, Michael Bayer wrote: well then yeah you need to do your own thing :) i foolishly thought this was something others may have experienced ;) i'd use inspect(obj) to get the mapper.but also you might want to use cascade_iterator:

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Mike Bayer
On 7/17/15 2:32 PM, Jonathan Vanasco wrote: editing the cascade isn't an option. well then yeah you need to do your own thing :) i'd use inspect(obj) to get the mapper.but also you might want to use cascade_iterator:

[sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
I'm updating our visual preview tool for edits, and ran into an issue. In order to best mimic the production view, I can't simply clone the objects any longer (they have way too many attributes and relationships) and must apply edits onto the real object. I'd like to ensure that changes

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Mike Bayer
On 7/17/15 2:18 PM, Jonathan Vanasco wrote: I'm updating our visual preview tool for edits, and ran into an issue. In order to best mimic the production view, I can't simply clone the objects any longer (they have way too many attributes and relationships) and must apply edits onto the real

Re: [sqlalchemy] marking an object read-only / recursive expunge?

2015-07-17 Thread Jonathan Vanasco
editing the cascade isn't an option. for now this seems to work, though it's ugly. def recursive_expunge(obj, dbSession): def _recursive_expunge(_obj): if hasattr(_obj, '__mapper__'): for rel in obj.__mapper__.relationships:

Re: [sqlalchemy] Issue with dynamically loaded modules and SQLAlchemy

2015-07-17 Thread Jeffrey McLarty
Thanks for the pointers; that was all I needed. Plunking around SQLA's PluginLoader and dialect.__init__.py with pdb...allowed me to figure out the problem. __import__ doesn't reload packages if they are already loaded, but the check to determine already loaded, obviously can't include a