Install cx_Oracle on Ubuntu

If you are still having trouble running sqlplus please refer to my previous article on how to install Oracle Client.

In order to install cx_Oracle open a Terminal and execute the following:


sudo -i

apt-get install python-pip python-dev build-essential

export ORACLE_HOME=/usr/lib/oracle/11.2/client

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

cd $ORACLE_HOME

ln -s libclntsh.so.x.x libclntsh.so

pip install cx_Oracle

Done!

 

Install Oracle client on Ubuntu Desktop 12 (32 bits)

As you know Oracle does not support Ubuntu. I was not able to find a link where it provides a step by step Oracle client installation. Therefore, I am going to provide them.

Step 1:
Open a Terminal and run the following:

sudo apt-get install alien

 

Step 2:

Go to http://www.oracle.com/technetwork/topics/linuxsoft-082809.html and download the following:
oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.i386.rpm
oracle-instantclient11.2-devel-11.2.0.3.0-1.i386.rpm

Step 3:

Go back to the terminal and move to the directory where you downloaded the files and execute the following:


sudo alien -i oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
sudo alien -i oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.i386.rpm
sudo alien -i oracle-instantclient11.2-devel-11.2.0.3.0-1.i386.rpm
sudo apt-get install libaio1
sudo vi /etc/ld.so.conf.d/oracle.conf and add /usr/lib/oracle/11.2/client/lib/
sudo ldconfig

Step 4

At this point sqlplus should be running from the terminal with no issues.

 

Add the following to .bashrc:

export ORACLE_HOME=/usr/lib/oracle/11.2/client
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

 

Step 5:

Execute the following:


source .bashrc

cd $ORACLE_HOME

sudo mkdir network

cd network/

sudo mkdir admin

cd admin

Step 6:

Put your tnsnames.ora file in /usr/lib/oracle/11.2/client/network/admin/

Done!

 

Perl Pie (aka perl -p -i -e)

Few days ago a co-worker came to me for an advice and he said the following “I have a huge file that has 2 million records and I would like to change a date in it from 04/29/2012 to 04/15/2012.” He emphasized that there was only one column that has that date.

In order to solve the problem I went ahead and executed this statement on unix command line:

$ perl -p -i -e 's|04/29/2012|04/15/2012|g' file

The run time was few seconds and all records got updated properly.