码尚云_西安云计算培训_云计算运维培训机构

标题: python mysql动态参数的处理详解 [打印本页]

作者: 云鼎    时间: 2022-9-19 14:24
标题: python mysql动态参数的处理详解
在做自动化过程中,经常会用到python操作mysql,但是操作过程中,插入的,修改的或者其他动作的一些参数可能是动态的,那么对于动态参数如何处理呢?小编进行了简单整理如下:


1、insert:
  • INSERT INTO drive_script_log VALUES ('{}', 1, 1, '{}' ,null ,null ,null )
  • """
  • inserSql = insertSql.format(idNum,ts)
  • Util().databaseInsert(inserSql)

[color=rgb(15, 199, 122) !important]复制代码



2、update:

  • sqls = 'UPDATE drive_script_log SET runstarttime="%s" WHERE id=%s' % (tsRunST, idNum)
  • Util().databaseUpdate(sqls)

[color=rgb(15, 199, 122) !important]复制代码

[color=rgb(15, 199, 122) !important]







欢迎光临 码尚云_西安云计算培训_云计算运维培训机构 (http://www.mashangcloud.com/) Powered by Discuz! X3.4