[sqlalchemy] Re: Default behavior for sqlalchemy_utils.UUIDType

2016-08-02 Thread Jason Libbey
I see, so I didn't quite understand the relationship between sqlalchemy and the sqlalchemy_utils libraries, but I think I've got it all straight now. To answer your question as to why I would need the dashes, it's because the other dependencies expect to be able to look up uuid by the standard

[sqlalchemy] Mapping sql tables and automatically creating classes for ORM manipulation

2016-08-02 Thread Shravan Murali
Hey guys ! I recently worked on an app with which you can generate classes for any number of SQL tables automatically , just by giving in the table names and database name through command line . https://github.com/shravan97/ORM-Creator I would certainly love to integrate this with SqlAlchem

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-08-02 Thread Mike Bayer
What I need is a complete .py file that sets up a *minimal* version of *every* class required, then the Query object, then prints it. I'll mangle it to do the right thing. Like this: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-08-02 Thread Brian Cherinka
So I managed to get something to return using this definition of the @expression, however, I'm not quite there yet. @hybrid_property def restwave(self): if self.target: redshift = self.target.NSA_objects[0].z wave = np.array(self.wavelength.wavelength)

Re: [sqlalchemy] nested subqueries in a hybrid expression?

2016-08-02 Thread Brian Cherinka
So I managed to get something to return using this definition of the @expression, however, I'm not quite there yet. @hybrid_property def restwave(self): if self.target: redshift = self.target.NSA_objects[0].z wave = np.array(self.wavelength.wavelength)

Re: [sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-08-02 Thread Mike Bayer
On 08/02/2016 10:14 AM, Lenar Imamutdinov wrote: The only problem with after_flush() is that it's a session event. Why there is no such event on instance level? because it would involve adding a loop that iterates through all the objects that were flushed and searching each one for event han

Re: [sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-08-02 Thread Lenar Imamutdinov
The only problem with after_flush() is that it's a session event. Why there is no such event on instance level? On Tuesday, August 2, 2016 at 4:37:19 PM UTC+3, Mike Bayer wrote: > > > > On 08/02/2016 04:24 AM, Lenar Imamutdinov wrote: > > Thank you for the comprehensive answer. Without going too

Re: [sqlalchemy] Re: DBAPI Error with SQLAlchemy-1.0.5

2016-08-02 Thread Mike Bayer
I'd recommend trying psycopg2 as the driver as it may handle this failure mode more gracefully. On 08/02/2016 04:34 AM, Simon King wrote: It looks like an exception is occurring, which SQLAlchemy has caught and is now trying to roll back the transaction before re-raising the initial exception

Re: [sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-08-02 Thread Mike Bayer
On 08/02/2016 04:24 AM, Lenar Imamutdinov wrote: Thank you for the comprehensive answer. Without going too much into details, I have a table where file associated with each database record, and the name of that file is based on object id. This is what's happening now when I'm doing an INSERT: 1

Re: [sqlalchemy] SAWarning shows not immediately, but after some time of app execution

2016-08-02 Thread TomS.
On 07/22/2016 05:13 PM, Simon King wrote: On Fri, Jul 22, 2016 at 3:25 PM, TomS. wrote: On 07/19/2016 06:41 PM, Mike Bayer wrote: On 07/19/2016 11:51 AM, TomS. wrote: Hi, We have Flask app which uses SQLAlchemy. Weird error started to happen recently. The difficulty is that we can't repro

Re: [sqlalchemy] Re: DBAPI Error with SQLAlchemy-1.0.5

2016-08-02 Thread Simon King
It looks like an exception is occurring, which SQLAlchemy has caught and is now trying to roll back the transaction before re-raising the initial exception. However, a second exception has occurred during the rollback, so you can no longer see the original exception. The second exception looks lik

Re: [sqlalchemy] refresh_flush is not triggered when only the primary key is updated

2016-08-02 Thread Lenar Imamutdinov
Thank you for the comprehensive answer. Without going too much into details, I have a table where file associated with each database record, and the name of that file is based on object id. This is what's happening now when I'm doing an INSERT: 1. Model instance is created 2. Explicit flush is d