On Tue, Apr 20, 2021 at 1:14 PM Mike Bayer <[email protected]> wrote:
>
>
> On Tue, Apr 20, 2021, at 1:52 PM, 'Matt Zagrabelny' via sqlalchemy wrote:
>
> Greetings SQLAlchemy,
>
> I'm attempting to use the next_value function to get the (next) value from
> a sequence:
>
> cycle_counter = next_value(Sequence('cycle_seq'))
> print(cycle_counter)
>
> However, the print statement yields:
>
> <next sequence value: cycle_seq>
>
> Does anyone know the correct way to get the value of a sequence?
>
>
>
> you should execute that with a connection:
>
> with engine.connect() as conn:
> conn.scalar(seq.next_value())
>
>
>
Thanks for the tip, Mike!
Best,
-m
--
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.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3WK0%3DF3gu_pouZhTx-Banwzyn90qT-WVa%3DJUiQW7x7VEA%40mail.gmail.com.