Re: [sqlalchemy] SQLAlchemy 1.1 cause core dump committing multiple dirty records outside of function where mutation happens

2017-08-22 Thread Konstantin Kashin
Alright... I was able to track this down to a cPython problem in Python 3.6.0. This reproes with SQLite as well. When moving to Python 3.6.2, this goes away. This fixed the culprit: https://github.com/serhiy-storchaka/cpython/commit/5aafff22a20715d276a23d30b7335bbecbc31754 On Tuesday, August

Re: [sqlalchemy] Set up a composite key using a foreign key and another column with Python

2017-08-22 Thread Mike Bayer
On Tue, Aug 22, 2017 at 9:42 PM, Joshua Peppeman wrote: > Hello, > > I asked this question on Reddit and StackOverflow without any luck getting > an answer. Here is the StackOverflow question. I'll paste it below again. > > > I have two tables set up in Python with

Re: [sqlalchemy] Re: getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread Mike Bayer
On Tue, Aug 22, 2017 at 6:46 PM, cecemel wrote: > Hello, > > thanks again for the answer. Perhaps my case was not clear enough. To make > it a bit more explicit, I updated the example accordingly. > > from sqlalchemy import event > > from sqlalchemy import * > from

[sqlalchemy] Set up a composite key using a foreign key and another column with Python

2017-08-22 Thread Joshua Peppeman
Hello, I asked this question on Reddit and StackOverflow without any luck getting an answer. Here is the StackOverflow question . I'll paste it below again. I have

Re: [sqlalchemy] Re: getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread cecemel
Hello, thanks again for the answer. Perhaps my case was not clear enough. To make it a bit more explicit, I updated the example accordingly. from sqlalchemy import event from sqlalchemy import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker,

Re: [sqlalchemy] making a relationship on a column operation

2017-08-22 Thread Jonathan Vanasco
and thank you x 100 -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received

Re: [sqlalchemy] making a relationship on a column operation

2017-08-22 Thread Jonathan Vanasco
On Tuesday, August 22, 2017 at 2:16:42 PM UTC-4, Mike Bayer wrote: > you're looking for: > > > http://docs.sqlalchemy.org/en/latest/orm/join_conditions.html#using-custom-operators-in-join-conditions > > > I swear I searched first and spent an hour trying to figure this out. And then

Re: [sqlalchemy] making a relationship on a column operation

2017-08-22 Thread Mike Bayer
On Tue, Aug 22, 2017 at 12:19 PM, Jonathan Vanasco wrote: > I can't seem to figure out how to transition a query for the Ip > Blocks/ranges than a given IP address exists in, from a generic query into a > relationship. i keep getting foreign key errors, not matter what

Re: [sqlalchemy] Re: getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread Mike Bayer
you would need to illustrate an MCVE of what's happening. objects don't "lose track" of their related objects unless yes, you deleted them, in which case you should not expect that they would be there. when the object is expired, it will go to reload them, and they'll be gone. On Tue, Aug 22,

[sqlalchemy] Re: getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread cecemel
@update: calling the flush doen't seem to make any difference. At some point, the object looses track of it's grandparents On Tuesday, August 22, 2017 at 3:57:23 PM UTC+2, cecemel wrote: > > Hi, > > so, I'm currently facing this issue, where I would like to do some calls > to an external

Re: [sqlalchemy] getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread cecemel
Hi, thanks for your reply. I am confused, it is during a delete that I should access the grandparent id of my object. (would if have been a add, I wouldn't be confused) If I do a flush, I actually would expect the ID's to be removed and the object to be completely 'unbound'. (So no linked

Re: [sqlalchemy] getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread Mike Bayer
On Tue, Aug 22, 2017 at 9:57 AM, cecemel wrote: > Hi, > > so, I'm currently facing this issue, where I would like to do some calls to > an external service, when my object has been deleted within a flush. > For this operation to occur, I need the id from my model object,

Re: [sqlalchemy] horizontal sharding and bulk_insert

2017-08-22 Thread Mike Bayer
On Tue, Aug 22, 2017 at 3:43 AM, Антонио Антуан wrote: > Hi guys > I tried to implement horizontal sharding in my project. Everything is ok, > except bulk_inserts. > When I run tests, I got this error: > File "/home/anton/Projects/proj/core/model/messages.py", line 210, in >

[sqlalchemy] getting model's grandparent after persistent_to_deleted event has fired.

2017-08-22 Thread cecemel
Hi, so, I'm currently facing this issue, where I would like to do some calls to an external service, when my object has been deleted within a flush. For this operation to occur, I need the id from my model object, but also the id from the parent of the parent object model. There are cases,

[sqlalchemy] Re: SQLAlchemy: backref and object loaded from DB not working?

2017-08-22 Thread cecemel
yep indeed, it works, I was doing something wrong. Thanks for all the help and sorry about late reply On Thursday, August 17, 2017 at 9:57:39 PM UTC+2, cecemel wrote: > > Is the backref relationship supposed to work with objects loaded from the > DB? > > > Here is the case: > > Similar to the

Re: [sqlalchemy] SQLAlchemy 1.1 cause core dump committing multiple dirty records outside of function where mutation happens

2017-08-22 Thread Simon King
On Tue, Aug 22, 2017 at 9:26 AM, Konstantin Kashin wrote: > # Setup > Suppose I have a table with two fields: a string primary key and a boolean > flag. I want to query multiple rows and then update the flag across all of > them, then commit my changes. I have a MySQL DB with

[sqlalchemy] SQLAlchemy 1.1 cause core dump committing multiple dirty records outside of function where mutation happens

2017-08-22 Thread Konstantin Kashin
# Setup Suppose I have a table with two fields: a string primary key and a boolean flag. I want to query multiple rows and then update the flag across all of them, then commit my changes. I have a MySQL DB with the following DBAPI

[sqlalchemy] horizontal sharding and bulk_insert

2017-08-22 Thread Антонио Антуан
Hi guys I tried to implement horizontal sharding in my project. Everything is ok, except bulk_inserts. When I run tests, I got this error: File "/home/anton/Projects/proj/core/model/messages.py", line 210, in create