Python测试案例

import psycopg2
import requests

conn = psycopg2.connect(
    host="10.10.10.10",
    database="it",
    user="test",
    password="test",
    port=8432
)

cur = conn.cursor()

# 查询语句
cur.execute(
    "select guid , wechat_groupid,group_wechat_content  from public.p_wechat_content where send_flag = 0")

rows = cur.fetchall()

# 打印结果
for row in rows:
    url = 'https://lang.com/api/itms_01_api_01_common_01_system/WeChatGroup_S1?'
    kw = {'chatID': row[1],
          'Content': row[2]}
    response = requests.post(url, params=kw)
    print(response.content.decode())
    print(row[0])
    cur.execute(
        "update public.p_wechat_content set send_flag  = 1  where guid  = %s", (row[0],))
    conn.commit()

cur.close()
conn.close()
import psycopg2
# TNS
conn = psycopg2.connect(
    host="10.10.10.10",
    database="it",
    user="test",
    password="test",
    port=8432
)
# 连接数据库
cur = conn.cursor()
# 查询语句
cur.execute(
    "  select\
            date_part('day', now() - a.u_time) delay_day,\
            b.emp_desc next_desc,\
            a.next_operator,\
            c.process_desc,\
            a.itsm_id,\
            a.itsm_title,\
            d.emp_desc,\
            a.c_time\
        from\
            public.p_itsm_status a,\
            public.s_user_info b,\
            public.m_process_info c,\
            public.s_user_info d\
        where\
            a.next_operator = b.emp_no\
            and a.next_process = c.guid\
            and a.c_emp_no = d.emp_no\
            and a.u_time <= now() + '-1 day'\
        order by\
            date_part('day', now() - a.u_time) desc\
    ")
# 游标
rows = cur.fetchall()

# 循环获取数据
for row in rows:
    print(row)
    cur.execute(
        "   insert\
                into\
            public.p_wechat_content1\
                ( wechat_emp_no,\
                group_wechat_content)\
            values( %s,\
'\
【IT运营管理平台通知】\n\
超时服务待处理\n\
超时天数: '||%s||'\n\
服务单号: '||%s||'\n\
服务标题: '||%s||'\n\
流程节点:'||%s||'\n\
请及时登陆系统处理!');\
", (row[2],row[0], row[4], row[5], row[3],))
    # 提交请求
    conn.commit()
# 关闭游标
cur.close()
# 关闭数据库连接
conn.close()
import cx_Oracle
import requests

conn = cx_Oracle.connect('LangSQMS/password123@10.10.10.10:1521/szdw')
cur = conn.cursor()

# 查询语句
cur.execute("SELECT distinct B.SQM_DRI ,'厂商未回复,请确认!' content  FROM SQMS.P_SUPPLIER_REPLY A,SQMS.M_SUPPLIER B WHERE A.SUPPLIER_GUID = B.GUID(+) AND A.REPLY_TIME IS NULL AND A.C_TIME < sysdate-1")

rows = cur.fetchall()

# 打印结果
for row in rows:
    url = 'https://lang.com/api/itms_01_api_01_common_01_system/WeChat_S1?EmpCodes='+row[0]+'&Content='+row[1]
    response = requests.post(url)
    print(response.content.decode())
    print(row[0])
    print(row[1])
    print(url)
    conn.commit()
cur.close()
conn.close()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值