perfy576
V2EX  ›  Rust

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

  •  
  •   perfy576 · Mar 25, 2022 · 2535 views
    This topic created in 1524 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   ·   4386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 00:10 · PVG 08:10 · LAX 17:10 · JFK 20:10
    ♥ Do have faith in what you're doing.