I have a parent child relationship which I construct from a data feed. At
the time of constructing the object graph I don't have access to the
primary keys of the entities, so I build up the object graph by using the
relationship attributes. My understanding was that I could perform a
session.m
Oooo the problem is not what I thought.
The problem is that in my 'new data' there is no new_child_2. This is an
expected case, as sometimes children disappear, so will update the post.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post
Okay let me answer my own question. The problem is that my parent-child
relationship does not have the delete-orphan cascade. So when I set the new
children, the old child_2 loses its parent (as is expected, because it's no
longer a child) and then there's an error because the DB has a not null
It seems to be related to the cascades happening recursively. The merge
cascade goes from the tassel thread to the head, and then again down from
the head to the tassel thread - which is kind of strange, I would expect
the cascades to only visit each node in the object graph at most once. The
s
Thanks for the explanation Mike! Seeing it now, I actually think there’s a
decent reason to want the current backerefs:
My understanding is that with session.merge in SQL Alchemy it’s possible to
draw a very clean line between entities that are persisted (or about to be
persisted on the next fl
I think Mike's suggestion was to construct the raw SQL string you want,
then reverse engineer to get the correct SQL Alchemy code, which you can
then use with your different models. For complicated SQL logic I think this
is a good practice in general.
You current question seems like a general SQL
Hi all,
Just sharing some perf insights into the bulk operation function
bulk_insert_mappings.
I was recently debugging a SQL Alchemy powered web app that was crashing
due to out of memory issues on a small Kubernetes node. It turned out to be
"caused" by an over optimistic invocation of bulk_ins
been investigating
> memory usage when loading data using memory_profiler and would be
> interested to find out about the best approach
>
> On Thu, 14 Nov 2019, 17:16 James Fennell, wrote:
>
>> Hi all,
>>
>> Just sharing some perf insights into the bulk operation fu
> However I cannot catch for this error, I can only catch for
"sqlalchemy.exc.ProgrammingError".
Why is that?
James
On Wed, Dec 4, 2019 at 6:03 PM Jonathan Vanasco
wrote:
>
> Personally, I would handle the check like this:
>
> ERRORS_UNDEFINED_TABLE = (psycopg2.errors.UndefinedTable, )
>
> t
Hey all! I'm having a problem using the bulk_save_objects function.
*Background*: I'm working on an application that updates state in a
database from an external feed. The process is: I read the feed, convert
the data into SQLAlchemy objects which are detached from the session and
then call sessio
Hi Ben,
Have you checked out bulk operations?
https://docs.sqlalchemy.org/en/13/orm/persistence_techniques.html#bulk-operations
Bulk operations provide a DB-agnostic API for doing large numbers of
inserts and/or updates. The speed up you see, compared to session.add,
depends on your database and
11 matches
Mail list logo