Python 2.7.14 Oracle connect

在安装好python 2.7 默认路径是c:\python27之后,设置环境变量

https://jingyan.baidu.com/article/8ebacdf02d3c2949f65cd5d0.html

once the installation is complete, add the following locations to the windows PATH variable: C:\Python27 and C:\Python27\Lib\site-packages

  1. 点击屏幕底部菜单栏中的“计算机”图标。

    windows10设置环境变量PATH

  2. 在弹出的窗口中点击顶部的“计算机”标签,然后在出现的菜单中点击“系统属性”选项。

    windows10设置环境变量PATH

  3. 在新的页面中,点击左侧导航栏中的“高级系统设置”。

    windows10设置环境变量PATH

  4. 在弹出的页面中, 点击下部的“环境变量”按钮。弹出环境变量的管理页面。

    windows10设置环境变量PATH

  5. 在环境变量的管理页面中,在下部列表框中找到Path变量, 单击选中, 然后点击下面的“编辑”按钮。

    windows10设置环境变量PATH

  6. 弹出的页面有两个输入框, 在“变量值”输入框的末尾添加你要增加的路径,格式为 ;全路径,即分号加路径。注意这里分号必须是英文分号。比如我在安装Python2.7后添加的部分如图所示。

    windows10设置环境变量PATH

  7. 7

    点击确定,设置完成

 

1.到oracle官网注册一个账号,然后下载Oracle Database Express Edition 11g Release 2 for Windows x32

http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html

安装完成后,默认的username 有两个 sys, system,对应的密码就是在你安装过程中要你输入的那个密码,还有自动产生一个默认的database xe.

2安装和使用教程可以查看这位兄弟的博客

https://www.cnblogs.com/cjw1115/p/6209439.html

3.安装完成之后如果想要查看安装的oracle是否真是32bit,可以查看这位兄弟的文章

https://blog.csdn.net/mrluoe/article/details/7261713

使用sqlplus命令

32bit

SQL> $ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Thu Aug 2 14:05:40 2018

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

64bit

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Wed Feb 15 16:19:43 2012

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bitProduction
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options


如果是64位,用sqlplus 连上之后会显示具体的位数信息,32位则不会显示。

4.从https://pypi.org/project/cx_Oracle/5.1.3/#files下载

cx_Oracle-5.1.3-12c.win32-py2.7.exe (295.1 kB)  Copy SHA256 hashSHA256

安装完成后,解压缩,将instantclient-basic-nt-12.2.0.1.0\instantclient_12_2里面的所有dll文件copy到C:\Python27\Lib\site-packages

打开cmd window

cd \

C:\>cd Python27

C:\Python27>python
Python 2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import cx_Oracle

>>> con=cx_Oracle.connect('username/password@127.0.0.1/xe')

>>> print con.version
11.2.0.2.0
>>> con.close()

 

5在pycharm或者visual studio

#import sys
#print(sys.path)

查看path 'C:\\Python27\\venv\\lib'

将site-packages 放到C:\Python27\venv\Lib 里面

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值