[sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread Михаил Доронин
I've tried to benchmark alchemy performance when inserting a lot of data. The results wasn't that good for sqlalchemy. The difference was up to three times in median values. First of all the more elements inserted the more the difference between sqlalchemy and executemany (mysqlclient). I've

[sqlalchemy] change history and (auto)flushing

2017-05-25 Thread YKdvd
I'm using "marshmallow-sqlalchemy" (mmsqla), a small wrapper around the "marshmallow" marshalling/serializing library. I'm using my defined mmsqla schemas to serialize a parent record with multi-level nested relationships and sending that to a webpage, which changes one of the relationship

Re: [sqlalchemy] Seeking Relationship Advice

2017-05-25 Thread mike bayer
On 05/25/2017 12:28 PM, SB wrote: I'm using SQLAlchemy in Flask and I'm trying to map a relationship between one point and another, but can't figure it out myself and am looking for help. I have Nodes that are physical things that only need to be defined once and then many instances of

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread Михаил Доронин
Wow, I've never saw this thing about multiple statements. Thanks! RTFM On Thursday, 25 May 2017 22:43:55 UTC+3, Mike Bayer wrote: > > > > On 05/25/2017 01:44 PM, Михаил Доронин wrote: > >> SQLAlchemy batches inserts in the ORM as

Re: [sqlalchemy] change history and (auto)flushing

2017-05-25 Thread mike bayer
On 05/25/2017 04:40 PM, YKdvd wrote: I'm using "marshmallow-sqlalchemy" (mmsqla), a small wrapper around the "marshmallow" marshalling/serializing library. I'm using my defined mmsqla schemas to serialize a parent record with multi-level nested relationships and sending that to a webpage,

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread mike bayer
the topic of performance is one that many years of effort have gone into. For background on this topic particularly inserts, see: http://docs.sqlalchemy.org/en/latest/faq/performance.html#i-m-inserting-400-000-rows-with-the-orm-and-it-s-really-slow for a detailed test suite that will

Re: [sqlalchemy] dialect's default_schema_name not used for MetaData object

2017-05-25 Thread ben4ever
> > the default schema is what the SQLAlchemy dialect assumes will be the > effective schema name **when we do not state the schema name explicitly** Ahh, now I understand! Thanks for the detailed explanation ;). you write your own dialect that explicitly injects the schema name into SQL Yes,

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread Михаил Доронин
> SQLAlchemy batches inserts in the ORM as is possible and with Core you > do this explicitly, both make use of cursor.executemany() which is then > determined by how the DBAPI handles it. Ummm. If that is true, why this line is used when I pass a list of values (its from visit_insert)?

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread Михаил Доронин
Sorry I can't post a benchmark here, because I'm not in the office. Maybe I will do that tomorrow. I use vmprof and can just share a link to the uploaded profile. Will that suite you? But I can say right now that I've passed only integers, not strings. Also mysqlclient encoding values if

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread mike bayer
On 05/25/2017 12:02 PM, Михаил Доронин wrote: Sorry I can't post a benchmark here, because I'm not in the office. Maybe I will do that tomorrow. I use vmprof and can just share a link to the uploaded profile. Will that suite you? I would much prefer if you can send a traditional cProfile

[sqlalchemy] Seeking Relationship Advice

2017-05-25 Thread SB
I'm using SQLAlchemy in Flask and I'm trying to map a relationship between one point and another, but can't figure it out myself and am looking for help. I have Nodes that are physical things that only need to be defined once and then many instances of those Nodes can be put onto drawings. I

[sqlalchemy] Re: Seeking Relationship Advice

2017-05-25 Thread SB
In my last code block I have a hard-coded drawing_id of 7 from a bad copy/paste, but this would just be the DrawingNode's drawing_id. On Thursday, May 25, 2017 at 11:28:48 AM UTC-5, SB wrote: > > I'm using SQLAlchemy in Flask and I'm trying to map a relationship between > one point and another,

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread Михаил Доронин
For Christ sake how to post a new message here and not just reply? And how to edit the old post? Arg! -- 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.

Re: [sqlalchemy] insert performance vs executemany and max_allowed_packet limit

2017-05-25 Thread mike bayer
On 05/25/2017 01:44 PM, Михаил Доронин wrote: SQLAlchemy batches inserts in the ORM as is possible and with Core you do this explicitly, both make use of cursor.executemany() which is then determined by how the DBAPI handles it. Ummm. If that is true, why this line is used when I pass a