在做自动化过程中,经常会用到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]
|
|