[sqlalchemy] how to prepare "get by primary key" query?

2013-04-02 Thread Roman Yakovenko
Hello. I am just starting with SQLAlchemy and have a small problem: my "get" query is compiled every time I use it. According to cProfile: ncalls tottime percall cumtime percall filename:lineno(function) 100.0000.0000.0020.000 /usr/local/lib/python2.7/dist-packages/SQLAlchem

Re: [sqlalchemy] discriminator_on_association example and association proxies

2013-04-02 Thread Michael Bayer
the Customer.comments attribute proxies through "comment_association" which is configured as a scalar.this should probably be improved in this particular recipe, but for starting assignment you need to assign a collection first: c1 = Customer() c1.comments = [] I don't ever use "discrimina

Re: [sqlalchemy] python: sqlalchemy - how do I ensure connection not stale using new event system

2013-04-02 Thread Michael Bayer
if you're doing a query that is causing the database connection to simply fail, then you'd need to address that issue primarily. you'd probably want to perform multiple insert statements, chunking about 5-10K records at at time. On Apr 2, 2013, at 1:26 PM, algotr8...@gmail.com wrote: > To cl

[sqlalchemy] discriminator_on_association example and association proxies

2013-04-02 Thread bruk.habtu
I was attempting to implement the example shown in https://github.com/ContextLogic/sqlalchemy/blob/master/examples/generic_associations/discriminator_on_association.py trace: https://gist.github.com/brukhabtu/2294f0873830243845db my code: https://gist.github.com/brukhabtu/1423c9825252ddcf85a5 Cu

[sqlalchemy] Re: python: sqlalchemy - how do I ensure connection not stale using new event system

2013-04-02 Thread algotr8der
To clarify my environment. I have a VM (Linux Redhat) which has MySQL server running on it. My script runs locally on the same machine. It is a simple script that is doing a insert many after processing/parsing a csv file. I don't have any web apps or anything of that nature. On Monday, April

[sqlalchemy] Re: python: sqlalchemy - how do I ensure connection not stale using new event system

2013-04-02 Thread algotr8der
I tried to include pool_recycle = 10 (seconds) in my create_engine call but that doesn't fix the problem. I still get the same error. Hmm On Monday, April 1, 2013 7:04:48 PM UTC-7, algot...@gmail.com wrote: > > I am using the sqlalchemy package in python. I have an operation that > takes som

[sqlalchemy] Re: python: sqlalchemy - how do I ensure connection not stale using new event system

2013-04-02 Thread algotr8der
Below is the traceback. When it attempts to perform the conn.execute(), which is the db insert is where it seems to realize the connection is stale. Traceback (most recent call last): File "myscript.py", line 126, in main() File "myscript.py", line 33, in main insert_data(final_dat

Re: [sqlalchemy] unexpected behavior with the orm

2013-04-02 Thread Michael Merickel
Mike, thanks for the clarification. I never noticed that particular implication of the default cascade! On Mon, Apr 1, 2013 at 1:23 PM, Michael Bayer wrote: > > On Apr 1, 2013, at 2:10 PM, Michael Merickel wrote: > > > I ran into a situation the other day where I would create a new object > but

Re: [sqlalchemy] Update object with results of a server-side processing [pgsql]

2013-04-02 Thread Alexey Vihorev
Wonderful! Thanks a lot. 2013/4/2 Michael Bayer > The insert() construct supports a call called returning() to emit whatever > RETURNING you want, but if you're using the ORM, then the insert() > construct is generated by your mappings. In this case, the ORM right now > favors being able to ba