V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
perfy576
V2EX  ›  Rust

使用 sqlx 如何打印出最终执行的 sql?

  •  
  •   perfy576 · Mar 25, 2022 · 2466 views
    This topic created in 1500 days ago, the information mentioned may be changed or developed.

    终端中打印的都是 select name, value, create_time, modify_time from base.table where name = ? limit 1

    的 sql ,但是 name = ? 的?最终赋值没有打印出来。 请问这里如何打印出来?

    另外,sqlx 有 escape 的方法吗??

    CEBBCAT
        1
    CEBBCAT  
       Mar 25, 2022 via iPhone
    你 prepare 了吧?
    perfy576
        2
    perfy576  
    OP
       Mar 27, 2022
    @CEBBCAT 代码里没这样


    let cur_next_id_result = sqlx::query_as::<_, NextId>("select name,value,create_time,modify_time from base.next_id where name = ? limit 1 for update")
    .bind(&body.name).fetch_one(&mut tr).await;

    差不多这样
    CEBBCAT
        3
    CEBBCAT  
       Mar 28, 2022
    @perfy576 着急要吗?不着急的话先看一遍这个库的文档
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2716 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:14 · PVG 21:14 · LAX 06:14 · JFK 09:14
    ♥ Do have faith in what you're doing.