Re: [sqlalchemy] sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'PPESSOA' expected to update 1 row(s); 0 were matched.

2023-09-06 Thread Leandro Lázaro
 I updated the driver to the latest version and removed the line
'self.engine.dialect.supports_sane_rowcount = False,' and the same error
occurred again. Could this driver also have an unknown bug?

TCLOUD_DATABASE_DRIVER_V18 =
"/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.3.so.1.1"

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_V18+'=yes=yes'

Em ter., 5 de set. de 2023 às 22:03, Leandro Lázaro <
leandrolazaro5...@gmail.com> escreveu:

> 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
>> <

Re: [sqlalchemy] sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'PPESSOA' expected to update 1 row(s); 0 were matched.

2023-09-05 Thread Leandro Lázaro
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_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_source=footer>
> .
>
>
> --
> SQLAlchemy -
> The Pyt

Re: [sqlalchemy] sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'PPESSOA' expected to update 1 row(s); 0 were matched.

2023-09-05 Thread Leandro Lázaro
 

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_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.


[sqlalchemy] sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'PPESSOA' expected to update 1 row(s); 0 were matched.

2023-08-22 Thread Leandro Lázaro
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/c2939c34-4d95-4fe8-b697-afc705b47a11n%40googlegroups.com.


[sqlalchemy] Sqlacodegen freeze when generate models.py

2023-08-01 Thread Leandro Lázaro
Hello,

When I use the command sqlacodegen mssql+pymssql://USER:PASS@IP:PORT/DB > 
model.py, the process hangs and continues running for several hours without 
any results. The database I'm trying to generate models.py for is quite 
large (over 1000 tables). Is the execution time normal, or is something 
wrong? I've tested the connection string with engine.connect(), and it 
seems to be working fine. Am I doing something wrong? Thank you in advance.

Best regards,

Leandro L. A. Vieira

-- 
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/1a9d575a-f87e-4ff8-a6de-dac0fd3b27fdn%40googlegroups.com.