[sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
I'm developing an application using the ORM, and I am getting into all sorts of trouble with what I think should be a pretty simple data model. I've tried following the ORM tutorial from the docs, but it seems to get me confused every time I try. So I'm looking for something else that maybe

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
On Friday, 10 January 2014 16:27:12 UTC, Kevin H wrote: It sounds to me like the problem you're having has to do with how you are getting the reference to the package, which isn't shown in your example. How are you getting it? The new_release() function is what I do - I create a new

Re: [sqlalchemy] Is there a good ORM tutorial? And advice on parent/child management

2014-01-10 Thread Paul Moore
On Friday, 10 January 2014 17:52:45 UTC, Michael Bayer wrote: there’s various patterns for dealing with the very common issue of “create unique object if not exists, else use the current one”. One that I frequently point to is the unique object recipe: OK, so looking at that seems to

[sqlalchemy] Integrity errors in foreign key with nullable=False in a large hierarchy

2014-01-09 Thread Paul Moore
The following is a stripped down example of my app, that does NOT show the problem: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, backref, sessionmaker from sqlalchemy import Column, Integer, String, ForeignKey from sqlalchemy import

Re: [sqlalchemy] Integrity errors in foreign key with nullable=False in a large hierarchy

2014-01-09 Thread Paul Moore
On Thursday, 9 January 2014 21:27:06 UTC, Michael Bayer wrote: I think one of the error tracebacks (sorry, I lost them in other output) mentioned autoflush - could the ORM be trying to flush bits of the hierarchy before it's complete? Is there a better fix than removing the nullable=False

Re: [sqlalchemy] Insert from JSON data (coping with unneeded fields and varying types)

2013-12-19 Thread Paul Moore
On Tuesday, 17 December 2013 20:43:33 UTC, Michael Bayer wrote: typically you should write marshaling code here using a schema library - though I’ve not used it, I’d recommend colander for this: http://docs.pylonsproject.org/projects/colander/en/latest/ Nice, thanks! I hadn't heard of

[sqlalchemy] Insert from JSON data (coping with unneeded fields and varying types)

2013-12-17 Thread Paul Moore
I'm trying to load data into a database from a JSON data source. In theory, my data (mostly) matches my database table schema - the data is a list of dictionaries, with keys for the various columns. But, as the source data is JSON, I can't be 100% certain it doesn't contain oddities. Also, some