perfy576
V2EX  ›  Rust

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

  •  
  •   perfy576 · Mar 25, 2022 · 2916 views
    This topic created in 1690 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
    CEBBCAT
    Mar 25, 2022 via iPhone
    1
    你 prepare 了吧?
    perfy576
    perfy576
    OP
    Mar 27, 2022
    2
    @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
    CEBBCAT
    Mar 28, 2022
    3
    @perfy576 着急要吗?不着急的话先看一遍这个库的文档
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1010 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:59 · PVG 02:59 · LAX 10:59 · JFK 13:59
    ♥ Do have faith in what you're doing.