Simon's answer was almost what I needed, but was missing the details about
using context.connection.scalar to run the query.
I ended up finding a very similar issue in another thread from a few months
ago
here: https://groups.google.com/d/msg/sqlalchemy/h71QfUtCCmw/U6ITbv5pFgAJ
Thank you both
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 almost going to ask if that's what you meant, but you didn't
specify that in your question. Simon's answer contains the
You can provide a function for the default value, and the function can
receive the current statement context as a parameter. This context
gives you access to the rest of the insert statement, including values
of other parameters:
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'Donovan-Jones
On 11/18/2016 09:10 AM, Alexander O'Donovan-Jones wrote:
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,
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 =