postgresql 数据库查询
来源:互联网 发布:悦游网络加速器免费版 编辑:程序博客网 时间:2024/06/03 19:58
#!/usr/local/bin/python
import psycopg2
conn = psycopg2.connect(database = "policy_pro", user = "policy_opr", password = "eWEeFZTGS5PkviKW", host = "10.200.18.1", port="3433")
print "Open database success"
cur = conn.cursor()
psql0 = "select template_id from signcreat.t_sign_template t where template_signature_type='01' and template_id > 1386 order by template_id"
cur.execute(psql0)
psqla = cur.fetchall()
# print psqla
i=0
j=56360526
for a in psqla:
psql = " select count(p.bill_no) from signcreat.t_sign_policy p where p.template_id = %s ; " % a[0]
cur.execute(psql)
rows = cur.fetchone()
j = j + rows[0]
print a[0], rows[0], j
i = i+1
print 'end'
# import os
# import time
#
# psql = ''' psql -h 10.200.18.1 -p 3433 -U policy_opr -d policy_pro -c " select count(p.bill_no) from signcreat.t_sign_policy p where p.template_id = 128 and is_del = '1' " '''
# a= os.popen(psql,'r')
# print a.read()
import psycopg2
conn = psycopg2.connect(database = "policy_pro", user = "policy_opr", password = "eWEeFZTGS5PkviKW", host = "10.200.18.1", port="3433")
print "Open database success"
cur = conn.cursor()
psql0 = "select template_id from signcreat.t_sign_template t where template_signature_type='01' and template_id > 1386 order by template_id"
cur.execute(psql0)
psqla = cur.fetchall()
# print psqla
i=0
j=56360526
for a in psqla:
psql = " select count(p.bill_no) from signcreat.t_sign_policy p where p.template_id = %s ; " % a[0]
cur.execute(psql)
rows = cur.fetchone()
j = j + rows[0]
print a[0], rows[0], j
i = i+1
print 'end'
# import os
# import time
#
# psql = ''' psql -h 10.200.18.1 -p 3433 -U policy_opr -d policy_pro -c " select count(p.bill_no) from signcreat.t_sign_policy p where p.template_id = 128 and is_del = '1' " '''
# a= os.popen(psql,'r')
# print a.read()
阅读全文
0 0
- postgresql 数据库查询
- postgresql数据库查询当前数据库、当前用户
- 查询PostgreSQL中的数据库是否存在
- postgresql 数据库时间间隔数据查询
- postgresql查询
- Oracle,SQLServer,Mysql,PostgreSQL数据库查询前10条比较
- tcp-h数据&postgresql查询(数据库学习之二)
- postgresql数据库查询所有字段详细信息,包括描述
- postgresql数据库查询所有索引详细信息,包括描述信息
- openlayers i查询功能(矢量图层、postgresql空间数据库)
- postgresql实现跨数据库查询,采用dblink的形式
- PostgreSQL数据库
- PostgreSQL数据库
- POSTGRESQL 数据库 数据库管理
- PostgreSQL中的模糊查询
- PostgreSQL的权限查询
- postgreSQL查询分页
- postgresql with 递归查询
- learn opencv-使用OpenCV进行Alpha混合(C ++ / Python)
- Zookeeper学习与实践(一)
- linux学习---线程同步(互斥量,信号量,条件量)线程属性
- 消费者生产者模式(2)——用java阻塞队列实现
- Java面试题——ArrayList和Linked区别
- postgresql 数据库查询
- WebSocket
- Joda-Time 用法
- 快速排序(QuickSort)的java实现
- HDU 1171 : Big Event in HDU
- Java实现简单图数据结构
- 5.5
- 【嵌入式学习历程5】 数组与函数(1)
- 我的Linux 的学习之路