Re: [sqlalchemy] In the onupdate function, how to get the value of the row of records to be updated

2021-06-22 Thread peizhi qin
before_ insert before_ update can solve my problem. Thank you very much

在2021年6月21日星期一 UTC+8 下午5:34:02 写道:

> I don't think you'll be able to get what you want in an onupdate
> function. You'd probably be better off with the before_insert and
> before_update mapper events:
>
>
> https://docs.sqlalchemy.org/en/14/orm/events.html#sqlalchemy.orm.MapperEvents.before_insert
>
>
> https://docs.sqlalchemy.org/en/14/orm/events.html#sqlalchemy.orm.MapperEvents.before_update
>
> Hope that helps,
>
> Simon
>
> On Sun, Jun 20, 2021 at 5:37 PM peizhi qin  wrote:
> >
> > I have a table ,the definition is as follows:
> > class TEnterprise(Base):
> > __tablename__ = 't_enterprise'
> > __table_args__ = (
> > {'mysql_engine': 'InnoDB', 'mysql_charset': 'latin1'}
> > )
> >
> > Fent_id = Column(String(32), primary_key=True)
> > Fent_type = Column(INTEGER(11), nullable=False)
> > Fcomb_cert_state = Column(INTEGER(11), nullable=False)
> > Fstate = Column(INTEGER(11), nullable=False)
> > Fbusiness_license_copy = Column(String(256), nullable=False)
> > Fbusiness_license_number = Column(String(32), nullable=False)
> > Fmerchant_name = Column(String(128), nullable=False)
> > Fsign = Column(String(64), nullable=False, server_default=text("''"))
> >
> > the Fsign=md5(Fcomb_cert_state=${Fcomb_cert_state}_id=${Fent_id})
> >
> > i can use context.current_parameters get the value of the field to be 
> updated, but how to get the value of the field that has not been updated, 
> thanks for help!
> >
> > --
> > 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/bc9a6c71-90dd-4c7a-a5a8-9712f43d24f6n%40googlegroups.com
> .
>

-- 
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/3a01b630-1b70-4add-8a9e-0783dccf3d8bn%40googlegroups.com.


Re: [sqlalchemy] In the onupdate function, how to get the value of the row of records to be updated

2021-06-21 Thread Simon King
I don't think you'll be able to get what you want in an onupdate
function. You'd probably be better off with the before_insert and
before_update mapper events:

https://docs.sqlalchemy.org/en/14/orm/events.html#sqlalchemy.orm.MapperEvents.before_insert

https://docs.sqlalchemy.org/en/14/orm/events.html#sqlalchemy.orm.MapperEvents.before_update

Hope that helps,

Simon

On Sun, Jun 20, 2021 at 5:37 PM peizhi qin  wrote:
>
> I have a table ,the definition is as follows:
> class TEnterprise(Base):
> __tablename__ = 't_enterprise'
> __table_args__ = (
> {'mysql_engine': 'InnoDB', 'mysql_charset': 'latin1'}
> )
>
> Fent_id = Column(String(32), primary_key=True)
> Fent_type = Column(INTEGER(11), nullable=False)
> Fcomb_cert_state = Column(INTEGER(11), nullable=False)
> Fstate = Column(INTEGER(11), nullable=False)
> Fbusiness_license_copy = Column(String(256), nullable=False)
> Fbusiness_license_number = Column(String(32), nullable=False)
> Fmerchant_name = Column(String(128), nullable=False)
> Fsign = Column(String(64), nullable=False, server_default=text("''"))
>
> the Fsign=md5(Fcomb_cert_state=${Fcomb_cert_state}_id=${Fent_id})
>
> i can use  context.current_parameters get the value of the field to be 
> updated, but how to get the value of the field that has not been updated, 
> thanks for help!
>
> --
> 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/bc9a6c71-90dd-4c7a-a5a8-9712f43d24f6n%40googlegroups.com.

-- 
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/CAFHwexfwaB5PUdvYj9sGukhtM36iWTc%2B41pG1vMdmV5dYLuVJA%40mail.gmail.com.


[sqlalchemy] In the onupdate function, how to get the value of the row of records to be updated

2021-06-20 Thread peizhi qin
I have a table ,the definition is as follows:
class TEnterprise(Base):
__tablename__ = 't_enterprise'
__table_args__ = (
{'mysql_engine': 'InnoDB', 'mysql_charset': 'latin1'}
)

Fent_id = Column(String(32), primary_key=True)
Fent_type = Column(INTEGER(11), nullable=False)
Fcomb_cert_state = Column(INTEGER(11), nullable=False)
Fstate = Column(INTEGER(11), nullable=False)
Fbusiness_license_copy = Column(String(256), nullable=False)
Fbusiness_license_number = Column(String(32), nullable=False)
Fmerchant_name = Column(String(128), nullable=False)
Fsign = Column(String(64), nullable=False, server_default=text("''"))

the Fsign=md5(Fcomb_cert_state=${Fcomb_cert_state}_id=${Fent_id})

i can use  context.current_parameters get the value of the field to be 
updated, but how to get the value of the field that has not been updated, 
thanks for help!

-- 
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/bc9a6c71-90dd-4c7a-a5a8-9712f43d24f6n%40googlegroups.com.