Category: Python


While executing a Python program, if you get this message “TypeError: an integer is required” , check which modules are imported. In fact, there are two methods for open(). One is a built-in function whereas the other is part of the os module.

So, if you do an import of all the methods of the os module like this way “from os import *“,  then your program will not use the open() built-in fonction. It will use os.open() instead.

Be careful !


Here is a HOWTO to access an Oracle base with Python.

There are two main ways : by compiling the cx_Oracle module source or transforming into a Debian package an ready-to-install rpm package.

I chose the second way. Download the rpm file suited for “CentOS 5 i386 RPM (Oracle 10g, Python 2.5)” at this address :

http://cx-oracle.sourceforge.net/

Check that the command-line program “alien” is present :

root@localhost:~# alien cx_Oracle-5.0.2-10g-py25-1.i386.rpm

A debian package is created : cx-oracle_5.0.2-2_i386.deb

To install it :

root@localhost:~# dpkg -i cx-oracle_5.0.2-2_i386.deb

To check that the module cx_Oracle is available :

fool@localhost:~$ python

Python 2.5.2 (r252:60911, Jan  4 2009, 17:40:26)
[GCC 4.3.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import cx_Oracle
>>>

You can now connect to the database Oracle through Python.

For more information about Python Database API Specification v2.0 :

Python Database API Specification v2.0

The official cx_Oracle documentation :

The official cx_Oracle documentation

Follow

Get every new post delivered to your Inbox.