python oracle数据库查询
需要本地拥有oracle_client环境
import cx_Oracle
import pandas
import pandas as pd
from sys import argv
import win32api,win32con
def getdays(y,m,d):
username = 'system'
passwd = ''
c_url = ':1521/cloud'
dsn_t=cx_Oracle.makedsn('',1521,service_name='cloud')
conn=cx_Oracle.connect(user=username,password=passwd,dsn=dsn_t)
conn.call_timeout=600000
#print(dsn_t)
dy=str(y)+'-'+str(m)+'-'+str(d)
cursor=conn.cursor()
sql="""SELECT PLATE_NUM from DBKFZY4X.P_PICRECORD where CAP_TIME between TO_DATE(\'"""+dy+""" """+"00"+""":"""+"00"+""":00\',\'YYYY-MM-DD hh24:mi:ss\') and TO_DATE(\'"""+dy+""" """+"23"+""":"""+"59"+""":59\', \'YYYY-MM-DD hh24:mi:ss\') group by PLATE_NUM"""
cursor.execute(sql)
resu=cursor.fetchall()
return len(resu)
USAGE='''
.exe 年 月 日
'''
y=input("年:")
m=input('月:')
d=input('日:')
print(y,m,d)
dy=getdays(y,m,d)
print(y+m+d+'共有不重复车牌数:'+str(dy))
win32api.MessageBox(0,y+m+d+'共有不重复车牌数:'+str(dy),'统计结果',win32con.MB_OK)
input('')