Re: [sqlalchemy] Encapsulate multiple columns into one

2015-09-24 Thread Yegor Roganov
Thanks, it worked. If someone is interested: class UrlBundle(Bundle): def __init__(self, *args, suffix='', **kwargs): super().__init__(*args, **kwargs) self._suffix = suffix def create_row_processor(self, query, procs, labels): s_proc =

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(), >

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

2015-09-24 Thread Sebastian M Cheung
class User(db.Model): id = db.Column(db.Integer, primary_key=True) mobile = db.Column(db.String(20), unique=False, nullable=False, info={'validators': InputRequired()}) activation_code = db.Column(db.String(6), unique=False, nullable=False, info={'validators': InputRequired()})

[sqlalchemy] loading of relationships

2015-09-24 Thread Julien Cigar
Hello, I'm using SQLAlchemy 1.0.8 with joinedload inheritance. On one of the Child I have a relationship property and I wondered if there is an easy way to innerjoin=True this relation only in a non-polymorphic context ? In my case I have the base class "Content", a child "Event", and "Event"

Re: [sqlalchemy] loading of relationships

2015-09-24 Thread Mike Bayer
On 9/24/15 9:32 AM, Julien Cigar wrote: Hello, I'm using SQLAlchemy 1.0.8 with joinedload inheritance. On one of the Child I have a relationship property and I wondered if there is an easy way to innerjoin=True this relation only in a non-polymorphic context ? In my case I have the base

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

2015-09-24 Thread Jonathan Vanasco
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 is causing "it [to] not work". > > To get a better understanding of "it did not work", I would look at the >

[sqlalchemy] "No such event 'instrument_class' for target" for mixin that needs to listen to 'instrument_class'

2015-09-24 Thread Chris Withers
Hi All, I have a mixin class here that I've factored out of one project as I want to use it in another one: https://github.com/Mortar/mortar_mixins/blob/master/mortar_mixins/temporal.py The problem is that

[sqlalchemy] Auto filter a relationship?

2015-09-24 Thread Shawn Adams
I've got the following models and I'd like to automatically filter out ReservationPackages that contain a "soft deleted" package. A package is "soft deleted" if deleted != null. I've been struggling with this for a few days now. The problem goes away if I don't use the proxy but then I cannot

[sqlalchemy] Re: Auto filter a relationship?

2015-09-24 Thread Jonathan Vanasco
I hit send early. That form should/will work for reading - i use it heavily. I'm not sure how/if it will interact with the collections management system (backref/backpopulates, etc). -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To

Re: [sqlalchemy] Re: Auto filter a relationship?

2015-09-24 Thread Shawn Adams
Jonathan, Are you suggesting I use this instead of the association_proxy on Reservation? Doing so will not let me have duplicate packages in the collections list. sqa filters them out. To get around that I had to use the association_proxy. On Thu, Sep 24, 2015 at 1:37 PM, Jonathan Vanasco

Re: [sqlalchemy] "No such event 'instrument_class' for target" for mixin that needs to listen to 'instrument_class'

2015-09-24 Thread Mike Bayer
On 9/24/15 2:06 PM, Chris Withers wrote: Hi All, I have a mixin class here that I've factored out of one project as I want to use it in another one: https://github.com/Mortar/mortar_mixins/blob/master/mortar_mixins/temporal.py The problem is that importing the module seems to result in

Re: [sqlalchemy] Re: Auto filter a relationship?

2015-09-24 Thread Jonathan Vanasco
Your use of association_proxy seems odd to me. That plugin is normally used to "cut out" the middleman when using a join with an association pattern and avoid a hop/remount a relationship from one object onto another. With my understanding and use of that plugin, you're basically setting the

[sqlalchemy] Re: Auto filter a relationship?

2015-09-24 Thread Jonathan Vanasco
packages = sa.orm.relationship("Package", primaryjoin="and_(ReservationPackage.package_id==Package.id, Package.deleted IS NOT NULL)") -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails

[sqlalchemy] Best way of filling a Pandas DataFrame from a SQLAlchemy Query

2015-09-24 Thread Maximilian Roos
This is mainly a pandas question, but wanted to ensure we didn't build something at pandas that used SQLAlchemy inefficiently. There are two main approaches: - Build a DataFrame from the results of a SQLAlchemy query; i.e. pandas has no knowledge that it's a SQL Query

Re: [sqlalchemy] "No such event 'instrument_class' for target" for mixin that needs to listen to 'instrument_class'

2015-09-24 Thread Chris Withers
On 24/09/2015 19:31, Mike Bayer wrote: sqlalchemy.exc.InvalidRequestError: No such event 'instrument_class' for target '' you need to make sure SQLAlchemy ORM is at least imported when that event handler is called and also you'd need to make sure propagate=True is on it because it's only a

Re: [sqlalchemy] Re: Auto filter a relationship?

2015-09-24 Thread Shawn Adams
Reservation -> packages is just a many-to-many relationship with the caveat that a reservation can have the same package more than once. Sqlalchemy will automatically dedube the packages collections which is not what I want. In order to avoid this I had to use reservation_packages as an