Re: [sqlalchemy] making a column type/operations dependent on postgresql version?

2017-03-07 Thread Jonathan Vanasco
> > the dialect has .server_version_info > > engine.dialect.server_version_info >= (9, 6) > > but you need your engine and connection to handle that. JSONB and JSON > have different operator support.So you might want to do a > TypeDecorator around it or similar but you can only support a

Re: [sqlalchemy] making a column type/operations dependent on postgresql version?

2017-03-07 Thread mike bayer
On 03/07/2017 03:49 PM, Jonathan Vanasco wrote: I'm deploying something and unsure of the underlying postgresql version for a given environment. most deployments are 9.6, a handful are 9.2. upgrading everything is not an option I have. i'm using declarative. the only issue I have right now,

[sqlalchemy] Re: making a column type/operations dependent on postgresql version?

2017-03-07 Thread Jonathan Vanasco
"within sqlalchemy". that was a typo. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. ---

[sqlalchemy] making a column type/operations dependent on postgresql version?

2017-03-07 Thread Jonathan Vanasco
I'm deploying something and unsure of the underlying postgresql version for a given environment. most deployments are 9.6, a handful are 9.2. upgrading everything is not an option I have. i'm using declarative. the only issue I have right now, is that JSONB is preferred to JSON support. Is

Re: [sqlalchemy] Re: Alembic or SQLAlchemy-Migrate

2017-03-07 Thread mike bayer
Hi John - "onupdate" is a Python side directive that does not impact the DDL of the column as created in the database, so it is not relevant to the ALTER TABLE directive. The equivalent to "server side ON UPDATE" for Postgresql would be a database trigger which is out of scope here. - mike

[sqlalchemy] Re: Alembic or SQLAlchemy-Migrate

2017-03-07 Thread John Robson
Hi Mike, you did an awesome tool, thank you very much!!! I started to use Alembic today, excellent tool, tutorial and "autogenerate" option ;) Up to now, everything is working well, except by this very small problem: class: created = Column(DateTime, server_default=func.now()) updated = Colum

Re: [sqlalchemy] Problems with sqlalchemy and timestamps

2017-03-07 Thread karl . lattimer
Yeah, you're sort of right - I wasn't getting the error reported for the initial failure, which was causing me pain. My logs aren't really up to scratch we're using docker with AWS and it's a PITA at times. I'm still not sure what was causing the original problem, but with some extra work it ap

[sqlalchemy] Re: Problems with sqlalchemy and timestamps

2017-03-07 Thread Lele Gaifax
karl.latti...@innolabs.uk writes: > current_time = datetime.datetime.utcnow() > s = current_time - datetime.timedelta(hours=1) > hour_ago = s.isoformat() > query = session.query(func.count(MyTable)).filter(MyTable > hour_ago) > ... > StatementError: (sqlalchemy.exc.InvalidRequestError) Can't recon