Thank you very much for your quick help. Yes, you are right, I was using the: "implicit_returning=False" flag on my "create_engine()".
I add the following, in case it can be useful to you: I removed the flag as suggested, and that's what I get now for the same code example (with sqlalchemy 1.4): Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python36\lib\site-packages\sqlalchemy\orm\session.py", line 3298, in flush self._flush(objects) File "C:\Python36\lib\site-packages\sqlalchemy\orm\session.py", line 3438, in _flush transaction.rollback(_capture_exception=True) File "C:\Python36\lib\site-packages\sqlalchemy\util\langhelpers.py", line 72, in __exit__ with_traceback=exc_tb, File "C:\Python36\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise_ raise exception File "C:\Python36\lib\site-packages\sqlalchemy\orm\session.py", line 3398, in _flush flush_context.execute() File "C:\Python36\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 456, in execute rec.execute(self) File "C:\Python36\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 633, in execute uow, File "C:\Python36\lib\site-packages\sqlalchemy\orm\persistence.py", line 247, in save_obj insert, File "C:\Python36\lib\site-packages\sqlalchemy\orm\persistence.py", line 1154, in _emit_insert_statements statement, multiparams, execution_options=execution_options File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1583, in _execute_20 return meth(self, args_10style, kwargs_10style, execution_options) File "C:\Python36\lib\site-packages\sqlalchemy\sql\elements.py", line 324, in _execute_on_connection self, multiparams, params, execution_options File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1462, in _execute_clauseelement cache_hit=cache_hit, File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1815, in _execute_context e, statement, parameters, cursor, context File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1999, in _handle_dbapi_exception util.raise_(exc_info[1], with_traceback=exc_info[2]) File "C:\Python36\lib\site-packages\sqlalchemy\util\compat.py", line 207, in raise_ raise exception File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line 1752, in _execute_context cursor, statement, parameters, context File "C:\Python36\lib\site-packages\sqlalchemy\dialects\postgresql\psycopg2.py", line 968, in do_executemany **kwargs TypeError: execute_values() got an unexpected keyword argument 'fetch' On Tuesday, August 31, 2021 at 4:24:24 PM UTC+2 Mike Bayer wrote: > Hi - > > Your test case is omitting a critical detail which we would assume is you > are using the "implicit_returning=False" flag on your create_engine(). > dont use this flag as it serves no useful purpose and that will fix your > issue here, we will be deprecating and removing this flag. > > will try to fix the immediate issue if possible. > > > On Tue, Aug 31, 2021, at 3:29 AM, Francesca L wrote: > > Hi group, > > I am tring to migrate from version *1.3.24* to *1.4.23* of SqlAlchemy, > using *PostgreSQL 10*. > > I found that the following code example works with 1.3, but triggers a > traceback with 1.4. > > import sqlalchemy > > session = ... > metadata = sqlalchemy.MetaData() > s_items = sqlalchemy.Sequence('s_items', start=1, increment=1, > metadata=metadata) > t_items = sqlalchemy.Table('t_items', metadata, > sqlalchemy.Column('id', sqlalchemy.Integer, s_items, primary_key = > True), > ) > metadata.drop_all(bind=session.bind) > metadata.create_all(bind=session.bind) > > class Item(object): > pass > > sqlalchemy.orm.mapper(Item, t_items) > > item1 = Item() > item2 = Item() > session.add_all([item1, item2]) > session.flush() > > This code, with 1.4 only, triggers the following traceback: > > Traceback (most recent call last): > File "C:\Python36\lib\site-packages\sqlalchemy\engine\base.py", line > 1672, in _execute_context > dialect, self, conn, execution_options, *args, **kw > File "C:\Python36\lib\site-packages\sqlalchemy\engine\default.py", line > 999, in _init_compiled > self._process_executemany_defaults() > File "C:\Python36\lib\site-packages\sqlalchemy\engine\default.py", line > 1838, in _process_executemany_defaults > if c.default and c.default.is_scalar: > AttributeError: 'Sequence' object has no attribute 'is_scalar' > > The only way I found to work around this with version 1.4, is to call *flush > *after each single *add*: > > item1 = Item() > session.add(item1) > session.flush() > item2 = Item() > session.add(item2) > session.flush() > > But this seems weird, to me. > Am I doing anything wrong? > Thank you very much for any suggestion. > > Francesca Leon > > > -- > 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+...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/c049bcf1-ff1c-4d78-b38f-6f2dba1a87e1n%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/c049bcf1-ff1c-4d78-b38f-6f2dba1a87e1n%40googlegroups.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/3af62c7e-9b82-4f5e-ab40-e94e5fd21619n%40googlegroups.com.