Re: Migration fails when changing to single table inheritance

2017-06-07 Thread Michael
Yes, I'll try Plan A first(do the INSERT FROM first) But mainly out of academic curiosity, if I were to start with a blank slate as you say, I'd still need to import the existing data that is currently in the non-inheritance table schema? So I guess I would just drop the database, upgrade to

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Oh right, I've used the @property decorator before, just been a while. Thanks for the explanation of @hybrid_property. Makes sense. On Wed, Jun 7, 2017 at 5:32 PM, mike bayer wrote: > > > On 06/07/2017 06:19 PM, Greg Silverman wrote: > >> Thanks, it worked! >> >> I

Re: Migration fails when changing to single table inheritance

2017-06-07 Thread Michael
Thanks for the insight Mike. I guess the best way to go about that would be to just call the raw insert sql statemen in the migration? like in https://stackoverflow.com/questions/23206562/sqlalchemy-executing-raw-sql-with-parameter-bindings/23206636#23206636 Since this app is not in production

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread mike bayer
On 06/07/2017 06:19 PM, Greg Silverman wrote: Thanks, it worked! I tried something similar using the @hybrid_property decorator, but could not get it to work. What exactly is the difference between that and the @property decorator? @property is super normal Python stuff that's in all the

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Thanks, it worked! I tried something similar using the @hybrid_property decorator, but could not get it to work. What exactly is the difference between that and the @property decorator? Greg-- On Wed, Jun 7, 2017 at 5:08 PM, mike bayer wrote: > > > On 06/07/2017

Re: Migration fails when changing to single table inheritance

2017-06-07 Thread mike bayer
On 06/07/2017 04:44 PM, Michael wrote: Hi all, I have a class called MediaChapter(Base), which I've refactored into MediaBase(Base) and MediaChapter(MediaBase) When I run the migration, I see: | psycopg2.IntegrityError:insert orupdate on table "mediachapter"violates foreign key constraint

Re: [sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread mike bayer
On 06/07/2017 02:31 PM, GMS wrote: I am sure this is easier than I am making it, but I just want to add a property to a class so that decimal representations get truncated at 3 decimal digits. My class is this: class Measures(Model): __tablename__= 'xcelera_measures' id=

Re: [sqlalchemy] Re: How to format class property as another accessible property

2017-06-07 Thread Greg Silverman
Hi, Thanks for pointing that out. It's still throwing the same error, even when changed. Does not seem to like passing the column name to the column_property method. Greg-- On Wed, Jun 7, 2017 at 3:30 PM, Jonathan Vanasco wrote: > These are two different lines of code.

Migration fails when changing to single table inheritance

2017-06-07 Thread Michael
Hi all, I have a class called MediaChapter(Base), which I've refactored into MediaBase(Base) and MediaChapter(MediaBase) When I run the migration, I see: psycopg2.IntegrityError: insert or update on table "mediachapter" violates foreign key constraint "fk_mediachapter_id_mediabase" DETAIL:

[sqlalchemy] Re: How to format class property as another accessible property

2017-06-07 Thread Jonathan Vanasco
These are two different lines of code. The second one looks correct. > value_new = column_property("%.3f" % value()) > value_new = column_property("%.3f" % value) > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please

[sqlalchemy] How to format class property as another accessible property

2017-06-07 Thread GMS
I am sure this is easier than I am making it, but I just want to add a property to a class so that decimal representations get truncated at 3 decimal digits. My class is this: class Measures(Model): __tablename__ = 'xcelera_measures' id = Column(Numeric, primary_key=True) studyidk