Access remote oracle database

657 views
Skip to first unread message

Humberto

unread,
Nov 24, 2011, 9:43:05 AM11/24/11
to web2py-users
Hi, I just started using web2py and I'm don't know how to connect to
my remote oracle database.

According with the chapter 6 of the official book the url should be
the following:

oracle://username/password@test

There are no parameters for the server ip address in the example, then
I tried this:

oracle://myusername/mypassword@server_ip_address/database_name

and

oracle://myusername/mypassword@server_ip_address:1521/database_name

None of them worked.

What I need to do in order to access my oracle database remotely?

Massimo Di Pierro

unread,
Nov 24, 2011, 1:30:04 PM11/24/11
to web2py-users
I think

oracle://myusername:mypassword@server_ip_address:1521/database_name

Humberto

unread,
Nov 24, 2011, 1:42:24 PM11/24/11
to web2py-users
web2py already comes with native oracle support? I installed pyodbc
and cx_oracle, but I still can't connect to my remote oracle database.

I tested a connection with postgres (I needed to install psycopg2) and
it's working fine.

Ps. My OS is Windows 7 x64.
Ps2. I tried running the web2py binary and from the source.

Massimo Di Pierro

unread,
Nov 24, 2011, 7:36:58 PM11/24/11
to web2py-users

Web2py supports oracle. Requires cxoracle and rinning from source.
What problem do you experience?

tomt

unread,
Nov 24, 2011, 8:35:52 PM11/24/11
to web2py-users
Do you have the oracle client installed on your web2py machine? If
you do, you should be able to test the connection to oracle with
'sqlplus database/password'.

oracle-instantclient is available for free from www.oracle.com/technetwork/index.html.
I'm using this on my linux machine to access a remote oracle server
using web2py. I believe this is also available for windows. I
installed three rpms, basic, sqlplus, and devel.

If you have the oracle client set up, you might want to test if you
can access oracle directly from python before trying it from web2py.

The cx_Oracle source has some good examples of how to do this.

If all this is already working, then post some of the specific errors
you are having and I'll try to help if I can.

- Tom


On Nov 24, 6:36 pm, Massimo Di Pierro <massimo.dipie...@gmail.com>
wrote:

Humberto Ferreira da Luz Junior

unread,
Nov 25, 2011, 5:48:09 AM11/25/11
to web...@googlegroups.com
I can access the remote database through SQL Developer and also from my local java applications.

My db.py:
db = DAL("oracle://user/pass...@server.ip:1521/dese")

Then when I try to access the database administration I get the following error:
<type 'exceptions.RuntimeError'>(Failure to connect, tried 5 times: 'NoneType' object has no attribute 'connect')

I'll try a simple python script using cx_oracle as you said.

Humberto Ferreira da Luz Junior
Mestrado - Ciência da Computação / UEL
Analista de Informática - ATI / UEL

Massimo Di Pierro

unread,
Nov 25, 2011, 11:37:59 AM11/25/11
to web2py-users
Looks like web2py cannot find cx_Oracle.

At startup, do you see Oracle listed as one of the available database
engines?


On Nov 25, 4:48 am, Humberto Ferreira da Luz Junior


<humbfd...@gmail.com> wrote:
> I can access the remote database through SQL Developer and also from my
> local java applications.
>
> My db.py:

> db = DAL("oracle://user/passw...@server.ip:1521/dese")

Humberto Ferreira da Luz Junior

unread,
Nov 25, 2011, 12:52:27 PM11/25/11
to web...@googlegroups.com
No, oracle is not listed at web2py startup.

I installed python 2.7 and cx_oracle 5.1.1-10g.win-amd64-py2.7.msi. Should I use an older version?


Humberto Ferreira da Luz Junior
Mestrado - Ciência da Computação / UEL
Analista de Informática - ATI / UEL



2011/11/25 Massimo Di Pierro <massimo....@gmail.com>

Humberto Ferreira da Luz Junior

unread,
Nov 25, 2011, 2:11:25 PM11/25/11
to web...@googlegroups.com
I tried python 2.6.6 with cx_oracle 5.1 and I got the same results. The oracle driver is not listed in the web2py console at startup (running from the source).

Massimo Di Pierro

unread,
Nov 25, 2011, 5:03:43 PM11/25/11
to web2py-users
start python (not web2py) and try

import cx_Oracle

does it work? If no the problem is with the installation of cx_Oracle.
If it works, than make sure you use the same python interpreter with
web2py.

On Nov 25, 1:11 pm, Humberto Ferreira da Luz Junior

Humberto Ferreira da Luz Junior

unread,
Nov 28, 2011, 5:17:58 AM11/28/11
to web...@googlegroups.com
I tried also with python 2.5, but without success.

Importing cx_oracle directly in a python script I got this error:
>>>import cx_Oracle
Traceback (most recent calls last):
   File "<stdin>", line 1, in <module>
ImportError: DLL load failed with error code 193.

I tried installing cx_oracle in my Ubuntu 11.10 and it worked fine, my problem is happening only on my windows 7 x64.

Humberto Ferreira da Luz Junior

unread,
Nov 28, 2011, 6:47:53 AM11/28/11
to web...@googlegroups.com
I also tried with the x86 python, but I got the same result.


Humberto Ferreira da Luz Junior
Mestrado - Ciência da Computação / UEL
Analista de Informática - ATI / UEL



2011/11/28 Humberto Ferreira da Luz Junior <humb...@gmail.com>

Massimo Di Pierro

unread,
Nov 28, 2011, 9:39:44 AM11/28/11
to web2py-users
This is a cx_Oracle issue. I suggest you contact the author. He may
have a mailing list.

On Nov 28, 4:17 am, Humberto Ferreira da Luz Junior

Humberto Ferreira da Luz Junior

unread,
Nov 28, 2011, 11:43:02 AM11/28/11
to web...@googlegroups.com
I solved the problem in cx_oracle mailing list.
That was happening because the Oracle Client wasn't installed (I was using only the SQL Developer to access the remote database).
I installed the oracle client (instantclient-basic-windows.x64-11.2.0.2.0), set the ORACLE_HOME variable and added it to PATH.
Now everything is working as should be.

Massimo, thanks by your help and patience.
Reply all
Reply to author
Forward
0 new messages