Linked Questions

Popular Questions

How do you handle generated/virtual MySQL columns in SQLAlchemy/Panacea (i.e. read-only column)?

I get an error when creating new elements: sqlalchemy tries to insert a column that is generated server side with MySQL 5.7's generated column.

class PyTest(Entity):
    x = Field(Integer, default=0)
    y = Field(Integer, default=1)
    z = Field(Integer)

    using_options(tablename="PyTest")

Where Z is the y+z serverside created from this statement

ALTER TABLE `test`.`PyTest` ADD COLUMN `z` INT AS (x + y);

Now on the following it crashes when trying to flush/commit a new element to the database. EX:

t2 = PyTest(x=10, y=1)

myscopedsession.merge(t2)
myscopedsession.flush()

The error is as follows:

sqlalchemy.exc.InterfaceError: (_mysql_exceptions.InterfaceError) (-1, 'error totally whack') [SQL: u'INSERT INTO `PyTest` (x, y, z) VALUES (%s, %s, %s)'] [parameters: (10, 1, None)]

Related Questions