标签:connect 大小 record 故障 name 查看 imp ica 执行sql
目的:删除数据库各个系统his库里的测试soe与故障数据;import os
import pymssql
import pprint
sql_name = [
qqqqq
]
print(‘****程序正在启动****‘)
os.environ[‘NLS_LANG‘] = ‘SIMPLIFIED CHINESE_CHINA.UTF8‘
os.environ[‘NLS_LANG‘] = ‘AMERICAN_AMERICA.AL32UTF8‘
for SJK in sql_name:
IP_HIS = SJK[0] # 获取数据库IP
us_HIS = SJK[1]
PW_HIS= SJK[2]
HIS = SJK[3]
print(HIS)
conn = pymssql.connect(host=IP_HIS, user=us_HIS, password=PW_HIS, database=HIS)
cur1 = conn.cursor()
check_sql1 = "DELETE FROM SOE WHERE sDevCode = ‘012400000001‘"
cur1.execute(check_sql1)
cur2 = conn.cursor()
check_sql2 = "DELETE FROM Fault_Record WHERE LOWER(sLineName) LIKE ‘%cs%‘ or sLineName LIKE ‘%测试%‘ or sLineName LIKE ‘%模拟%‘"
cur2.execute(check_sql2)
conn.close()
解析:主要在sql上,
DELETE FROM Fault_Record WHERE LOWER(sLineName) LIKE ‘%cs%‘ or sLineName LIKE ‘%测试%‘ or sLineName LIKE ‘%模拟%
其中,模糊查询用like ,忽略大小写用lower或者upper都可以。
标签:connect 大小 record 故障 name 查看 imp ica 执行sql
原文地址:http://blog.51cto.com/14135595/2342874