It worked!!! Thank you very much, it solved my problem. I was already going crazy haha. I will try to update the driver to solve the problem right at the root. Just a doubt: Changing to false does not generate any side effects?
Em ter., 5 de set. de 2023 às 21:16, Mike Bayer < mike_not_on_goo...@zzzcomputing.com> escreveu: > we will work around what is likely some kind of driver related error: > > engine = create_engine(".... your engine string normally .. ") > engine.dialect.supports_sane_rowcount = False > > > then run the program normally. the UPDATE will succeed. however, after > the program runs, look in the database and make sure the UPDATE took effect > correctly. if so, the driver, either pyodbc, or the ODBC driver in use, > has an unknown bug. try updating drivers, both pyodbc and the ODBC driver > in use. > > > On Tue, Sep 5, 2023, at 6:50 PM, Leandro Lázaro wrote: > > Hello, apologies for the delay. > > I'm using SQL Server. Updates using the code below work normally. However, > when I try to change the object directly and apply commit, I receive the > mentioned error. > > stmt = update(PPESSOA).where(PPESSOA.CODIGO == > ppessoa.CODIGO).values(EMAILPESSOAL=data['EMAIL']) > session.execute(stmt) > session.commit() > > The connection string is: > SQLALCHEMY_TCLOUD_DATABASE_URI = > 'mssql://'+TCLOUD_DATABASE_USERNAME+':'+TCLOUD_DATABASE_PASSWORD_UPDATED+'@ > '+TCLOUD_DATABASE_HOST+':'+TCLOUD_DATABASE_PORT+'/'+TCLOUD_DATABASE_NAME+'?driver='+TCLOUD_DATABASE_DRIVER > > Driver is: > > libmsodbcsql-17.10.so.4.1 > > Thank you for all! > > > Em terça-feira, 22 de agosto de 2023 às 15:51:47 UTC-3, Mike Bayer > escreveu: > > > if it's fully reproducible every time with both statements, then this > suggests something is happening with the database server itself, such as > some kind of issue with triggers getting involved or something. In > particular if this is MS SQL Server and there are triggers involved, the > updated rowcount might not be working correctly and extra steps might need > to be taken to turn off SQLAlchemy's rowcount facilities. > > you want to turn on `echo=True` and see that the expected UPDATE statement > takes place. Then you might want to try running those UPDATE statements > directly on the database and see that they work. > > What database backend, what database driver, and is the issue only > reproducible in a single environment or can it be reproduced elsewhere? > > > On Tue, Aug 22, 2023, at 2:42 PM, Leandro Lázaro wrote: > > Hello > > First, thanks for building this library. God bless you > > > I've been trying to understand what's going on for days. > > This code works fine: > > https://pastebin.com/fLTnB8jy > > But if I try to modify any other parameter like PERSONAL EMAIL I get the > error: > > sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'PPESSOA' > expected to update 1 row(s); 0 were matched > > Example: https://pastebin.com/EwdwLRcp > > Tank you > > > -- > 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/c2939c34-4d95-4fe8-b697-afc705b47a11n%40googlegroups.com > <https://groups.google.com/d/msgid/sqlalchemy/c2939c34-4d95-4fe8-b697-afc705b47a11n%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/65034fdf-0743-4f6a-8f4b-7b947364880dn%40googlegroups.com > <https://groups.google.com/d/msgid/sqlalchemy/65034fdf-0743-4f6a-8f4b-7b947364880dn%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/77ef55c9-9c91-48c4-a1df-5e7fe121e3cd%40app.fastmail.com > <https://groups.google.com/d/msgid/sqlalchemy/77ef55c9-9c91-48c4-a1df-5e7fe121e3cd%40app.fastmail.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/CAEKDjrkbZPwyBySd10fBzUiBFyd0a6LqPB4kNXQTduO5Li4w1w%40mail.gmail.com.