python 连接 oracle,,pip instal
python 连接 oracle,,pip instal
pip install cx_Oracle下载oracel 客户端 instantclient-basic-windows.x64-18.5.0.0.0dbru.zip ,不下载客户端可能有以下报错:
DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help
解压文件到脚本 的下级目录,或者设置路径到环境变量
#encoding=utf-8import cx_Oracle as oracleimport os#print(os.environ["path"])set_path = os.environ["path"]oracle_path = "..\\instantclient_18_5"os.environ["path"] = ';'.join((set_path,oracle_path)) # oracle 路径 暂时加到 环境变量 #print(os.environ["path"])def checkCodeFor2(): print("##########查询2号验证码#############\n") db = oracle.connect("账号", "密码", 'ip:1521/库名') cur = db.cursor() while(1): emp_id = input("请输入查询的ID:\n") if emp_id: try: cur.execute('select a.code,a.id from db_test a where a.id={}'.format(emp_id)) #cursor.execute('select 1;') data = cur.fetchone() print(data) check_sign = input("是否继续查询:Y/y 是 /N 否,其他任意字符都退出\n") if check_sign.lower() == "y": pass else: return 0 except oracle.DatabaseError as e: msg_error = e print("可能数据输入错误,请检查数据正确性,错误:\n{}".format(msg_error)) else: passif __name__=="__main__": checkCodeFor2()
python 连接 oracle
相关内容
- 21天学习python编程_函数参数,理解 *args和**kwargs,,主要
- python学习-01,,1、编程语言分类:
- python输入输出之用户名密码,,方法一: 1 # A
- Python——jieba库初使用,, 今日一言:“从来
- Python Selenium实现无可视化界面,,无可视化界面的意义有
- python并发编程-gevent使用大全,,一、gevent实现
- python使用安装ipdb,,1、安装python
- Python循环练习题,,1、输入n的值,求出
- centos6.5 安装python3.8,,最近购买了一台云服务
- Python之禅中的几句话--传说中的蛇宗总纲,,Simple is
评论关闭