[sqlalchemy] Syntax for contained by DateRange

2017-01-06 Thread Alexander O'Donovan-Jones
Does anyone know what the syntax for using DateRanges is? I'm trying to find out if a given date falls within a range, and so thought that the `in` syntax in Python might work (to no avail): from psycopg2.extras import DateRange session.query(Order).filter(Order.created_at in DateRange(d1, d2,

[sqlalchemy] Re: Hybrid expressions and element in arrays ala lists in Python

2016-12-27 Thread Alexander O'Donovan-Jones
I worked out a solution that allowed me to get the behaviour I was looking for, but instead of using func.array() I ended up using the postgresql.dialect module and it's array class: from sqlalchemy.dialects.postgresql import TIMESTAMP, array @travel_dates.expression def travel_dates(cls):

[sqlalchemy] Hybrid expressions and element in arrays ala lists in Python

2016-12-21 Thread Alexander O'Donovan-Jones
Hello everyone, I've wrestling with a problem to do with hybrid queries and Postgres that I'm hoping you can help me with. I'm trying to express the concept of 'element in list' for SQL using hybrid properties. The data I'm using is a nested JSON object like this: { "itinerary": {

Re: [sqlalchemy] Column value determined as a function return on INSERT

2016-11-21 Thread Alexander O'Donovan-Jones
for your help! :) On Friday, 18 November 2016 16:55:36 UTC, Mike Bayer wrote: > > > > On 11/18/2016 11:25 AM, Alexander O'Donovan-Jones wrote: > > That's a cool idea, but it would need to reference the instance we've > > created to use the `id` atribute. > > I was

Re: [sqlalchemy] Column value determined as a function return on INSERT

2016-11-18 Thread Alexander O'Donovan-Jones
That's a cool idea, but it would need to reference the instance we've created to use the `id` atribute. ie the sql would be `select max(version)+1 from responses where id = :id` On Friday, 18 November 2016 14:39:52 UTC, Mike Bayer wrote: > > > > On 11/18/2016 09:10 AM, Alexander O'D

[sqlalchemy] Column value determined as a function return on INSERT

2016-11-18 Thread Alexander O'Donovan-Jones
I'm currently working on using the ORM features of sqlalchemy with a legacy database table. The table can be roughly described like this: class APIResponse(Base): __tablename__ = 'responses' id = Column(Text, primary_key=True) version = Column(Integer, primary_key=True) payload =