Re: [sqlalchemy] Disabling implicit lazy loading

2015-07-24 Thread Yegor Roganov
Thanks, you are as always very helpful. I hope I'll be able to compose a PR soon. On Thursday, July 23, 2015 at 5:39:52 PM UTC+3, Michael Bayer wrote: On 7/23/15 10:09 AM, Mike Bayer wrote: On 7/23/15 1:24 AM, Yegor Roganov wrote: Hi all! Is there a way to disable implicit

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
will this answer my second question? obj._sa_instance_state.committed_state {'batch_status': STARTED(db=1), 'updated_by': 24769797950537744L, 'updated_on': Arrow [2015-07-24T14:02:03.360479-03:00]} cheers, richard. On 07/24/2015 11:13 AM, Richard Gerd Kuesters wrote: hi! first, /yes/, set

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Mike Bayer
On 7/24/15 10:13 AM, Richard Gerd Kuesters wrote: hi! first, /yes/, set and after_flush are quite different events :) but here's what i'm trying to accomplish: one object have an attribute, like 'state', and i would like to monitor and trigger some other methods if (given scenarios): 1.

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
On 07/24/2015 12:59 PM, Mike Bayer wrote: On 7/24/15 10:13 AM, Richard Gerd Kuesters wrote: hi! first, /yes/, set and after_flush are quite different events :) but here's what i'm trying to accomplish: one object have an attribute, like 'state', and i would like to monitor and trigger

[sqlalchemy] sessions and threads

2015-07-24 Thread 'Chris Norman' via sqlalchemy
Hi all, Seems I can't do session.query in anything other than the main thread. I'm using SQLite, and I'm not sure if it's a problem with that or SQLAlchemy it's self. Is there any kind of work around for this? Cheers, -- You received this message because you are subscribed to the Google

Re: [sqlalchemy] sessions and threads

2015-07-24 Thread Mike Bayer
On 7/24/15 4:14 PM, 'Chris Norman' via sqlalchemy wrote: Hi all, Seems I can't do session.query in anything other than the main thread. I'm using SQLite, and I'm not sure if it's a problem with that or SQLAlchemy it's self. Is there any kind of work around for this? Unfortunately the

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
obj._sa_instance_state.committed_state.get('key') == obj._sa_instance_state.dict.get('key') False is this all that's necessary to track down what's modified and the past state (i believe to be sa_instance_state.dict) ? cheers, richard. On 07/24/2015 11:34 AM, Richard Gerd Kuesters wrote:

Re: [sqlalchemy] UTC timestamps for Column's server_default?

2015-07-24 Thread Randy Syring
So helpful! Thanks. *Randy Syring* Chief Executive Developer Direct: 502.276.0459 Office: 812.285.8766 Level 12 https://www.level12.io/ On 07/24/2015 03:45 PM, Mike Bayer wrote: On 7/24/15 3:17 PM, Randy Syring wrote: I have some generic timestamp columns as part of a mixin. I'd like for

Re: [sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
well, as a general non-specific view yes, it can be another approach. but, for the piece of code that drove me to this question, i really need to use after_flush :) cheers, richard. On 07/24/2015 02:15 PM, Jonathan Vanasco wrote: Couldn't you handle much of this with the Descriptors/Hybrids

[sqlalchemy] Syntax Checking

2015-07-24 Thread Rich Shepard
Because this is my first SQLAlchemy project and the schema file has 657 lines I would like to check for syntax errors before proceeding with the next step in application development. I find no index in the SA manual and cannot find the string 'syntax check' in the PDF file. Web search turns up

[sqlalchemy] Re: performance of SA

2015-07-24 Thread Jonathon Nelson
On Fri, Jul 24, 2015 at 1:25 PM, Jonathan Vanasco jvana...@gmail.com wrote: Are you comparing the speed of SqlAlchemy Core operations or SqlAlchemy ORM operations? The ORM is considerably slower. The core engine is much faster. Core. -- Jon Nelson Dyn / Senior Software Engineer p. +1

Re: [sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Jonathan Vanasco
On Friday, July 24, 2015 at 1:20:15 PM UTC-4, Richard Kuesters wrote: well, as a general non-specific view yes, it can be another approach. but, for the piece of code that drove me to this question, i really need to use after_flush :) Well I mean... you could use that pattern to catch

Re: [sqlalchemy] Syntax Checking

2015-07-24 Thread Mike Bayer
On 7/24/15 1:49 PM, Rich Shepard wrote: Because this is my first SQLAlchemy project and the schema file has 657 lines I would like to check for syntax errors before proceeding with the next step in application development. I find no index in the SA manual and cannot find the string 'syntax

[sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Jonathan Vanasco
Couldn't you handle much of this with the Descriptors/Hybrids pattern? http://docs.sqlalchemy.org/en/latest/orm/mapped_attributes.html#using-descriptors-and-hybrids -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe from this group and

Re: [sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
well, application-wise it is really to run other procedures, not from the database or python side, but from a message broker that's expecting anything to happen to that value -- even if it's just a touch :) err ... it's quite a specific architecture for dumb clients, so i'm just taking some

[sqlalchemy] Re: performance of SA

2015-07-24 Thread Jonathan Vanasco
Are you comparing the speed of SqlAlchemy Core operations or SqlAlchemy ORM operations? The ORM is considerably slower. The core engine is much faster. There is also this: http://docs.sqlalchemy.org/en/latest/faq/performance.html -- You received this message because you are subscribed to

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Mike Bayer
On 7/24/15 10:45 AM, Richard Gerd Kuesters wrote: obj._sa_instance_state.committed_state.get('key') == obj._sa_instance_state.dict.get('key') False is this all that's necessary to track down what's modified and the past state (i believe to be sa_instance_state.dict) ? I'd prefer you use

Re: [sqlalchemy] set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
yes, a public api would be awesome, perhaps for a future version? :) for now, i'll stick to that -- since it works, heh. cheers, richard. On 07/24/2015 12:59 PM, Mike Bayer wrote: On 7/24/15 10:45 AM, Richard Gerd Kuesters wrote: obj._sa_instance_state.committed_state.get('key') ==

[sqlalchemy] set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
hi! first, /yes/, set and after_flush are quite different events :) but here's what i'm trying to accomplish: one object have an attribute, like 'state', and i would like to monitor and trigger some other methods if (given scenarios): 1. the program sets a new value to a state that is

Re: [sqlalchemy] performance of SA

2015-07-24 Thread Mike Bayer
On 7/24/15 2:19 PM, Jonathon Nelson wrote: I should preface this by saying I'm a huge fan of SQLAlchemy. Huge! However, when trying to extol the virtues of SQLAlchemy I inevitably run into this issue: But it's slow! My usual response to that is that, yes, it is somewhat slower than raw

Re: [sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Richard Gerd Kuesters
yeah, that's basically what i'm doing: gathering information about what's happening and sending a response as quick as i can, since most of the clients are step machines (they still exists), so ... :) On 07/24/2015 04:01 PM, Jonathan Vanasco wrote: On Friday, July 24, 2015 at 2:06:15 PM

Re: [sqlalchemy] Syntax Checking

2015-07-24 Thread Rich Shepard
On Fri, 24 Jul 2015, Mike Bayer wrote: Python syntax or SQL syntax? Mike, The former. Typically in Python we rely on linters and runtime checks for this, same idea with SQL. Have not used a lint before with Python, but will run it on my SQLAlchemy code. I know that SQLite and

Re: [sqlalchemy] UTC timestamps for Column's server_default?

2015-07-24 Thread Mike Bayer
On 7/24/15 3:17 PM, Randy Syring wrote: I have some generic timestamp columns as part of a mixin. I'd like for these columns to have server defaults of the current UTC time. If I wanted local time, I could just do: created_ts = Column(DateTime, ...,

Re: [sqlalchemy] Syntax Checking

2015-07-24 Thread Jonathan Vanasco
flake8 is super simple - it checks your code for mistakes (undeclared vars, non-runnable code, etc) and pushes you to write pep8 style code. the only things you need to do really are: * write a .cfg for various projects, so you can turn off some warnings * get in the habit of running it before

Re: [sqlalchemy] Syntax Checking

2015-07-24 Thread Jonathan Vanasco
In terms of linters, `flake8` (https://pypi.python.org/pypi/flake8) catches most mistakes I've made with SqlAlchemy. It's also useful to start writing Unit Tests that will interact with your SqlAlchemy models in predicted ways -- in addition to continually checking core functionality. -- You

Re: [sqlalchemy] performance of SA

2015-07-24 Thread Mike Bayer
On 7/24/15 2:44 PM, Mike Bayer wrote: On 7/24/15 2:19 PM, Jonathon Nelson wrote: I should preface this by saying I'm a huge fan of SQLAlchemy. Huge! However, when trying to extol the virtues of SQLAlchemy I inevitably run into this issue: But it's slow! My usual response to that is

Re: [sqlalchemy] Re: set vs after_flush events

2015-07-24 Thread Jonathan Vanasco
On Friday, July 24, 2015 at 2:06:15 PM UTC-4, Richard Kuesters wrote: well, application-wise it is really to run other procedures, not from the database or python side, but from a message broker that's expecting anything to happen to that value -- even if it's just a touch :) err ...

[sqlalchemy] UTC timestamps for Column's server_default?

2015-07-24 Thread Randy Syring
I have some generic timestamp columns as part of a mixin. I'd like for these columns to have server defaults of the current UTC time. If I wanted local time, I could just do: created_ts = Column(DateTime, ..., server_default=sasql.text('CURRENT_TIMESTAMP')) The problem I'm running into is

Re: [sqlalchemy] Syntax Checking

2015-07-24 Thread Rich Shepard
On Fri, 24 Jul 2015, Jonathan Vanasco wrote: In terms of linters, `flake8` (https://pypi.python.org/pypi/flake8) catches most mistakes I've made with SqlAlchemy. It's also useful to start writing Unit Tests that will interact with your SqlAlchemy models in predicted ways -- in addition to

[sqlalchemy] performance of SA

2015-07-24 Thread Jonathon Nelson
I should preface this by saying I'm a huge fan of SQLAlchemy. Huge! However, when trying to extol the virtues of SQLAlchemy I inevitably run into this issue: But it's slow! My usual response to that is that, yes, it is somewhat slower than raw MySQL or PostgreSQL or whatever DB-API you are