Re: [sqlalchemy] Domain models and "leaky abstractions"

2015-11-16 Thread David Allouche
> On 13 Nov 2015, at 09:16, Yegor Roganov wrote: > > Suppose we have a 1 <-> N relation between users and cities (meaning that > every user is related with one city). For our domain model "User" we want to > define a method "lives_in_london". Code looks like this: > >

Re: [sqlalchemy] SQLTap 0.3.10 released

2015-10-03 Thread David Allouche
> On 2 Oct 2015, at 05:49, George Reilly <george.v.rei...@gmail.com> wrote: > > On Mon, Sep 28, 2015 at 1:04 AM, David Allouche <da...@allouche.net > <mailto:da...@allouche.net>> wrote: >> On 28 Sep 2015, at 05:21, George V. Reilly <george.v.re

Re: [sqlalchemy] SQLTap 0.3.10 released

2015-09-28 Thread David Allouche
> On 28 Sep 2015, at 05:21, George V. Reilly wrote: > > SQLTap is a very useful library that helps you in profiling SQLAlchemy > queries. It helps you understand where and when SQLAlchemy issues queries, > how often they are issued, how many rows are returned, and

Re: [sqlalchemy] how to dynamically work with an aliased table?

2015-09-25 Thread David Allouche
> On 24 Sep 2015, at 17:38, Jonathan Vanasco <jonat...@findmeon.com> wrote: > > > > On Thursday, September 24, 2015 at 3:05:56 AM UTC-4, David Allouche wrote: > That looks like the right approach. There is probably something else in your > actual code that i

Re: [sqlalchemy] Re: How to get specific attribute from last row?

2015-09-24 Thread David Allouche
> On 23 Sep 2015, at 20:37, Sebastian M Cheung > wrote: > > posts = User.query.all() > row = posts.select().execute().fetchone() > print row[-1] > return row.activation_code > > doesnt work Why are you doing this? Instead of, for example: posts =

Re: [sqlalchemy] how to dynamically work with an aliased table?

2015-09-24 Thread David Allouche
> On 23 Sep 2015, at 20:38, Jonathan Vanasco wrote: > > I have a query where I derive an object based on some dynamic filters on a > relationship: > > sql_ors = [ > sqlalchemy.func.lower(Bar.string_id) == id_search.lower(), >

Re: [sqlalchemy] Raise exception on implicit join

2015-07-28 Thread David Allouche
On 28 Jul 2015, at 11:31, Jacob Magnusson m...@jacobian.se wrote: I'm trying to avoid implicit joins (i.e. more than one entry in the FROM clause) in my code and I'm wondering if you guys have a good idea on how to best achieve this. I want to raise an exception if a query changes to have

Re: [sqlalchemy] What is the terminology for ...?

2015-06-11 Thread David Allouche
On 11 Jun 2015, at 19:09, Tony C cappy2...@gmail.com wrote: I'm new to databases, SQL, and SQLAlchemy. I've been going through the tutorials and docs at SQLAlchemy.org trying to find a solution to what I believe is a very simple issue with database quiries, however I'm quite uncertain of

Re: [sqlalchemy] ...and MVC

2015-05-26 Thread David Allouche
On 26 May 2015, at 09:16, Burak Arslan burak.ars...@arskom.com.tr wrote: same here but before passing the model instance from controller to view, all instances are detached from session (via expunge()). this 1) prevents a lot of unexpected db queries. 2) lets you recycle db connections as

Re: [sqlalchemy] when do I have to do a rollback so the app keep working fine

2015-04-27 Thread David Allouche
On 18 Apr 2015, at 02:20, dcgh...@gmail.com wrote: Hi everyone, I have a considerably amount of code that uses SQLAlchemy and I want to implement a decorator that captures the SQLAlchemy exceptions, then make session.rollback() and recall the decorated function, so I don't have to write