Python论坛  - 讨论区

标题:[python-chinese] 请教一下python怎么连oracle?

2007年11月21日 星期三 18:06

赵威 zhaowei在pythonid.com
星期三 十一月 21 18:06:05 HKT 2007

Fenix,您好!

	  python连接oracle数据库的动态库的下载地址
http://www.python.net/crew/atuining/cx_Oracle/

这是一段测试小程序:

import cx_Oracle

connection = cx_Oracle.connect("用户名", "密码", "数据库")

cursor = connection.cursor()
cursor.arraysize = 15
cursor.execute("""select fnxh,fcjym,fcjymc from tryxrz""")

for fnxh,fcjym,fcjymc in cursor.fetchall():
        print str(fnxh)+" "+str(fcjym)+" "+str(fcjymc)

在python2.5+cx_oracle3.4.1+oracle9.2上测试通过.



python调用cx_Oracle开发(-)---cx_Oracle安装
上面是windows的,接下来是linux的,是转的别人的帖子,原帖地址在这里
http://blog.csdn.net/LIUYANG007/archive/2007/03/16/1531167.aspx

开始在ubuntu下用python调用oracle,决定使用cx_Oracle.
安装前要确定oracle安装成功并能正常使用
在cx_Oracle的网站上http://www.python.net/crew/atuining/cx_Oracle/
有windows和linux 2种安装版本
按照自己的具体配置选择下载版本,我是oracle10,python 2.4
下载Fedora Core 5 RPM (Oracle 10g, Python 2.4),
cx_Oracle-4.3-10g-py24-1.i386.rpm
先把rpm转换成deb安装
suod alien cx_Oracle-4.3-10g-py24-1.i386.rpm cx_Oracle-4.3-10g-py24-1.i386.deb
再安装deb
sudo dpkg -i cx_Oracle-4.3-10g-py24-1.i386.deb
安装完成后在python里输入
>>> import cx_Oracle
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
经过查找发现是oracle的路径没有设置
输入:
locate libclntsh.so.10.1
获取对于路径
/app/oracle/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
编辑/etc/ld.so.conf
sudo gedit /etc/ld.so.conf
在最后一行输入获取的路径
/app/oracle/oracle/product/10.2.0/db_1/lib/
保存,关闭gedit
执行
ldconfig
再调用就好了



======= 2007-11-21 17:04:24 您在来信中写道:=======

>赵威,您好!
>    非常感谢,可惜这个网页我打不开,烦劳你如果方便的话,直接贴到邮件里 
>吧,谢谢 :-P
>
>
>赵威 写道:
>> Fenix,您好!
>>
>>     cx_Oracle
>> 	http://www.pythonid.com/bbs/viewthread.php?tid=33&extra;=page%3D1
>>
>> ======= 2007-11-21 16:28:10 您在来信中写道:=======
>>
>>   
>>> thanks!我用ubuntu的,有没有apt安装的法子?
>>>
>>> Liming_Do 写道:
>>>     
>>>> cx_Oracle
>>>>
>>>> -----Original Message-----
>>>> From: python-chinese-bounces在lists.python.cn
>>>> [mailto:python-chinese-bounces在lists.python.cn]On Behalf Of Fenix
>>>> Sent: Wednesday, November 21, 2007 4:05 PM
>>>> To: python-chinese在lists.python.cn
>>>> Subject: [python-chinese] 请教一下python怎么连oracle?
>>>>
>>>>
>>>> 我刚学python,以前是搞java的,请大家多指教,谢谢 :-)
>>>>
>>>> _______________________________________________
>>>> python-chinese
>>>> Post: send python-chinese在lists.python.cn
>>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>> _______________________________________________
>>>> python-chinese
>>>> Post: send python-chinese在lists.python.cn
>>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>       
>>> _______________________________________________
>>> python-chinese
>>> Post: send python-chinese在lists.python.cn
>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>     
>>
>> = = = = = = = = = = = = = = = = = = = =
>> 			
>>
>>         致
>> 礼!
>>  
>> 				 
>>         赵威
>>         zhaowei在pythonid.com
>>           2007-11-21
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        赵威
        zhaowei在pythonid.com
          2007-11-21


[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月21日 星期三 18:15

Fenix fenixkis在tom.com
星期三 十一月 21 18:15:09 HKT 2007

一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071121/c83e4574/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月22日 星期四 08:50

Liming_Do Liming_Do在smics.com
星期四 十一月 22 08:50:48 HKT 2007

真是个细心的好人^_^

-----Original Message-----
From: python-chinese-bounces在lists.python.cn
[mailto:python-chinese-bounces在lists.python.cn]On Behalf Of 赵威
Sent: Wednesday, November 21, 2007 6:06 PM
To: python-chinese在lists.python.cn
Subject: Re: [python-chinese]请教一下python怎么连oracle?


Fenix,您好!

	  python连接oracle数据库的动态库的下载地址
http://www.python.net/crew/atuining/cx_Oracle/

这是一段测试小程序:

import cx_Oracle

connection = cx_Oracle.connect("用户名", "密码", "数据库")

cursor = connection.cursor()
cursor.arraysize = 15
cursor.execute("""select fnxh,fcjym,fcjymc from tryxrz""")

for fnxh,fcjym,fcjymc in cursor.fetchall():
        print str(fnxh)+" "+str(fcjym)+" "+str(fcjymc)

在python2.5+cx_oracle3.4.1+oracle9.2上测试通过.



python调用cx_Oracle开发(-)---cx_Oracle安装
上面是windows的,接下来是linux的,是转的别人的帖子,原帖地址在这里
http://blog.csdn.net/LIUYANG007/archive/2007/03/16/1531167.aspx

开始在ubuntu下用python调用oracle,决定使用cx_Oracle.
安装前要确定oracle安装成功并能正常使用
在cx_Oracle的网站上http://www.python.net/crew/atuining/cx_Oracle/
有windows和linux 2种安装版本
按照自己的具体配置选择下载版本,我是oracle10,python 2.4
下载Fedora Core 5 RPM (Oracle 10g, Python 2.4),
cx_Oracle-4.3-10g-py24-1.i386.rpm
先把rpm转换成deb安装
suod alien cx_Oracle-4.3-10g-py24-1.i386.rpm cx_Oracle-4.3-10g-py24-1.i386.deb
再安装deb
sudo dpkg -i cx_Oracle-4.3-10g-py24-1.i386.deb
安装完成后在python里输入
>>> import cx_Oracle
Traceback (most recent call last):
  File "", line 1, in ?
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
经过查找发现是oracle的路径没有设置
输入:
locate libclntsh.so.10.1
获取对于路径
/app/oracle/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
编辑/etc/ld.so.conf
sudo gedit /etc/ld.so.conf
在最后一行输入获取的路径
/app/oracle/oracle/product/10.2.0/db_1/lib/
保存,关闭gedit
执行
ldconfig
再调用就好了



======= 2007-11-21 17:04:24 您在来信中写道:=======

>赵威,您好!
>    非常感谢,可惜这个网页我打不开,烦劳你如果方便的话,直接贴到邮件里 
>吧,谢谢 :-P
>
>
>赵威 写道:
>> Fenix,您好!
>>
>>     cx_Oracle
>> 	http://www.pythonid.com/bbs/viewthread.php?tid=33&extra;=page%3D1
>>
>> ======= 2007-11-21 16:28:10 您在来信中写道:=======
>>
>>   
>>> thanks!我用ubuntu的,有没有apt安装的法子?
>>>
>>> Liming_Do 写道:
>>>     
>>>> cx_Oracle
>>>>
>>>> -----Original Message-----
>>>> From: python-chinese-bounces在lists.python.cn
>>>> [mailto:python-chinese-bounces在lists.python.cn]On Behalf Of Fenix
>>>> Sent: Wednesday, November 21, 2007 4:05 PM
>>>> To: python-chinese在lists.python.cn
>>>> Subject: [python-chinese] 请教一下python怎么连oracle?
>>>>
>>>>
>>>> 我刚学python,以前是搞java的,请大家多指教,谢谢 :-)
>>>>
>>>> _______________________________________________
>>>> python-chinese
>>>> Post: send python-chinese在lists.python.cn
>>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>> _______________________________________________
>>>> python-chinese
>>>> Post: send python-chinese在lists.python.cn
>>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>>       
>>> _______________________________________________
>>> python-chinese
>>> Post: send python-chinese在lists.python.cn
>>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>>>     
>>
>> = = = = = = = = = = = = = = = = = = = =
>> 			
>>
>>         致
>> 礼!
>>  
>> 				 
>>         赵威
>>         zhaowei在pythonid.com
>>           2007-11-21
>>
>> _______________________________________________
>> python-chinese
>> Post: send python-chinese在lists.python.cn
>> Subscribe: send subscribe to python-chinese-request在lists.python.cn
>> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>_______________________________________________
>python-chinese
>Post: send python-chinese在lists.python.cn
>Subscribe: send subscribe to python-chinese-request在lists.python.cn
>Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
>Detail Info: http://python.cn/mailman/listinfo/python-chinese

= = = = = = = = = = = = = = = = = = = =
			

        致
礼!
 
				 
        赵威
        zhaowei在pythonid.com
          2007-11-21

_______________________________________________
python-chinese
Post: send python-chinese在lists.python.cn
Subscribe: send subscribe to python-chinese-request在lists.python.cn
Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月22日 星期四 09:00

Zoom.Quiet zoom.quiet在gmail.com
星期四 十一月 22 09:00:35 HKT 2007

On Nov 21, 2007 6:15 PM, Fenix <fenixkis在tom.com> wrote:
>
>  太谢谢了,我也琢磨得差不多,搞定了,哈哈
搞定了就回馈教程,体验哪!

>  明天看看怎么用sqlobject
>
>  赵威 写道:
>
>  Fenix,您好!
>
>  python连接oracle数据库的动态库的下载地址
> http://www.python.net/crew/atuining/cx_Oracle/
>
> 这是一段测试小程序:
>
> import cx_Oracle
>
> connection = cx_Oracle.connect("用户名", "密码", "数据库")
>
> cursor = connection.cursor()
> cursor.arraysize = 15
> cursor.execute("""select fnxh,fcjym,fcjymc from tryxrz""")
>
> for fnxh,fcjym,fcjymc in cursor.fetchall():
>  print str(fnxh)+" "+str(fcjym)+" "+str(fcjymc)
>
> 在python2.5+cx_oracle3.4.1+oracle9.2上测试通过.
>
>
>
> python调用cx_Oracle开发(-)---cx_Oracle安装
> 上面是windows的,接下来是linux的,是转的别人的帖子,原帖地址在这里
> http://blog.csdn.net/LIUYANG007/archive/2007/03/16/1531167.aspx
>
> 开始在ubuntu下用python调用oracle,决定使用cx_Oracle.
> 安装前要确定oracle安装成功并能正常使用
> 在cx_Oracle的网站上http://www.python.net/crew/atuining/cx_Oracle/
> 有windows和linux 2种安装版本
> 按照自己的具体配置选择下载版本,我是oracle10,python 2.4
> 下载Fedora Core 5 RPM (Oracle 10g, Python 2.4),
> cx_Oracle-4.3-10g-py24-1.i386.rpm
> 先把rpm转换成deb安装
> suod alien cx_Oracle-4.3-10g-py24-1.i386.rpm
> cx_Oracle-4.3-10g-py24-1.i386.deb
> 再安装deb
> sudo dpkg -i cx_Oracle-4.3-10g-py24-1.i386.deb
> 安装完成后在python里输入
>
>
>
>
>  import cx_Oracle
>
>  Traceback (most recent call last):
>  File "", line 1, in ?
> ImportError: libclntsh.so.10.1: cannot open shared object file: No such file
> or directory
> 经过查找发现是oracle的路径没有设置
> 输入:
> locate libclntsh.so.10.1
> 获取对于路径
> /app/oracle/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
> 编辑/etc/ld.so.conf
> sudo gedit /etc/ld.so.conf
> 在最后一行输入获取的路径
> /app/oracle/oracle/product/10.2.0/db_1/lib/
> 保存,关闭gedit
> 执行
> ldconfig
> 再调用就好了
>
>
>
> ======= 2007-11-21 17:04:24 您在来信中写道:=======
>
>
>
>  赵威,您好!
>  非常感谢,可惜这个网页我打不开,烦劳你如果方便的话,直接贴到邮件里
> 吧,谢谢 :-P
>
>
> 赵威 写道:
>
>
>  Fenix,您好!
>
>  cx_Oracle
>  http://www.pythonid.com/bbs/viewthread.php?tid=33&extra;=page%3D1
>
> ======= 2007-11-21 16:28:10 您在来信中写道:=======
>
>
>
>
>  thanks!我用ubuntu的,有没有apt安装的法子?
>
> Liming_Do 写道:
>
>
>
>  cx_Oracle
>
> -----Original Message-----
> From: python-chinese-bounces在lists.python.cn
> [mailto:python-chinese-bounces在lists.python.cn]On Behalf Of Fenix
> Sent: Wednesday, November 21, 2007 4:05 PM
> To: python-chinese在lists.python.cn
> Subject: [python-chinese] 请教一下python怎么连oracle?
>
>
> 我刚学python,以前是搞java的,请大家多指教,谢谢 :-)
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>  _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
>  = = = = = = = = = = = = = = = = = = = =
>
>
>         致
> 礼!
>
>
>         赵威
>         zhaowei在pythonid.com
>           2007-11-21
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>  _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>  = = = = = = = = = = = = = = = = = = = =
>
>
>         致
> 礼!
>
>
>         赵威
>         zhaowei在pythonid.com
>           2007-11-21
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>



-- 
'''Time is unimportant, only life important!
过程改进乃是开始催生可促生靠谱的人的组织!
'''http://zoomquiet.org
博 @ http://blog.zoomquiet.org/pyblosxom/
维 @ http://wiki.woodpecker.org.cn/moin/ZoomQuiet
豆 @ http://www.douban.com/people/zoomq/
看 @ http://zoomq.haokanbu.com/
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Pls. usage OOo to replace M$ Office. http://zh.openoffice.org
Pls. usage 7-zip to replace WinRAR/WinZip.  http://7-zip.org
You can get the truely Freedom 4 software.

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年11月22日 星期四 10:07

Fenix fenixkis在tom.com
星期四 十一月 22 10:07:03 HKT 2007

一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20071122/ab2c8a03/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号