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 any help!
> 
> -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 sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3UWDoh4n%2BQpj%3DBDOK616TpOEfn46ZQ%2BCo88c5VQyVK%3DZA%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/CAOLfK3UWDoh4n%2BQpj%3DBDOK616TpOEfn46ZQ%2BCo88c5VQyVK%3DZA%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/d9b21e34-c0fa-4840-b4de-059f271ad978%40www.fastmail.com.

Reply via email to