V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
annirg
V2EX  ›  问与答

flask pymysql 查询语句问题

  •  
  •   annirg · 2020-02-26 00:20:21 +08:00 · 481 次点击
    这是一个创建于 1693 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 flask pysql 查询 mysql:

    sql="select client_ip, result, date_time from ipset where client_ip='commit_ip'"

    返回是空的,把 commit_ip 换成 222.222.222.222 就能查询出来,不清楚 commit_ip 这个变量要怎么定义? commit_ip 是 html post 过来的,mysql 里的 client_ip 数据类型是 char(15),这个语句应该怎么写呢?

    annirg
        1
    annirg  
    OP
       2020-02-26 01:10:38 +08:00
    已解决, client_ip= %s ,cursor.execute(sql,(commit_ip,))
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3766 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:23 · PVG 18:23 · LAX 03:23 · JFK 06:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.