SQLPython 1.7.1 not connecting to Oracle db.

54 views
Skip to first unread message

wam

unread,
Mar 12, 2010, 11:43:00 AM3/12/10
to sqlpython
So, I'm fairly new to Oracle dbs and using sqlplus for a little while
certainly made me yearn for something better so I went to sqlpython.
Once I got it running (working around the cmd2/python3 issue), I've
been unable to get it to connect to my database using either an entry
in tnsnames.ora or with explicitly listing the connection parameters
on the command line. In all these examples, I'm using shell variables
that are defined and set to the proper value. I'm also killing
vertical whitespace for clarity.

Demonstrating that my variables are set correctly and that sqlplus
makes the connection:

$ sqlplus $my_user/$my_pw@$my_db_sid
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 12 11:23:04
2010
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit
Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining
Scoring Engine options
SQL>

And using sqlpython:

$ sqlpython "oracle://${my_user}:${my_pw}@${my_db_sid}"
/bin/sh: xclip: not found
Connection failure.
Opens the DB connection. Some sample valid connection strings:
[connect help deleted by wam]
SQL.No_Connection>


Note that even though I have a connection failure, the help message
for connect still is displayed, even though my URL is correct (or at
least it appears to be).

I then tried connecting with the specific connection parameters:

Using sqlplus:
$ sqlplus "${my_user}/${my_pw}
@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=$my_ip)
(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=
$my_db_name)))"
<snipped>
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit
Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining
Scoring Engine options
SQL>

Using sqlpython with URL syntax:

$ sqlpython "oracle://${my_user}:${my_pw}@${my_ip}:1521/$
{my_db_name}"
/bin/sh: xclip: not found
Connection failure.
Opens the DB connection. Some sample valid connection strings:
[snip]
SQL.No_Connection>

Using sqlpython with option syntax:
$ sqlpython --oracle -U ${my_user} --password ${my_pw} -H ${my_ip} -
p 1521 -d ${my_db_name}
/bin/sh: xclip: not found
Existing connections:

SQL.No_Connection>

Note that in that last invocation, I didn't snip any output at all.
There was no "Connection failure" message. There was no help message
displayed. But, there also was no valid connection. Any assistance or
pointers would very much be appreciated.

-- William

P.S. This is all being run from an Ubuntu 9.10 (Karmic) system with
the Oracle Client 10G Express Edition (oracle-xe-
client_10.2.0.1-1.0_i386.deb) installed.

wam

unread,
Mar 17, 2010, 12:18:29 PM3/17/10
to sqlpython
Looks like this can mostly be written off as user error. I was going
to spend some time debugging this and ran the command and got the same
error, and then realized that the shell I had opened to begin testing
hadn't sourced oracle_env.sh yet. I sourced the file, then re-ran
sqlpython and got connected. More than likely, this was my problem
originally as well. The error message returned and the differences in
the error messages displayed when using different connection
approaches was confusing and could probably be improved. Perhaps a
stern warning when attempting to connect to a Oracle db without having
either ORACLE_HOME or SQLPATH defined would make this condition a lot
easier to diagnose.

-- William

Catherine Devlin

unread,
Mar 17, 2010, 2:35:07 PM3/17/10
to sqlp...@googlegroups.com
Ah, that's a good idea.  I failed to duplicate your error but didn't email about it, b/c I'm now working with a trunk version where connection is in flux.

Really, ultimately, I hope to get really good feedback written for connection failures; I'm a big fan of informative error messages (even though you might not see that from the current version of sqlpython...)

--
You received this message because you are subscribed to the Google Groups "sqlpython" group.
To post to this group, send email to sqlp...@googlegroups.com.
To unsubscribe from this group, send email to sqlpython+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlpython?hl=en.




--
- Catherine
http://catherinedevlin.blogspot.com/
*** PyCon * Feb 17-25, 2010 * Atlanta, GA * us.pycon.org ***

donkeyx

unread,
Mar 20, 2010, 8:11:40 AM3/20/10
to sqlpython
Hey Guys,

I am also running oracle but cannot connect and do not get any error
message of the failure:
<code>
[me@MacBook software]$ sqlplus $dbuser/$dbp...@test.worldSQL*Plus:
Release 10.2.0.4.0 - Production on Sat Mar 20 22:00:07 2010

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit
Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL>
</code>

now with sqlpython :

<code>
[me@MacBook software]$ sqlpython oracle://moodle:m00...@test.WORLD
/bin/sh: xclip: command not found


Connection failure.
Opens the DB connection. Some sample valid connection strings:

</code>

My environment :

<code>
[me@MacBook software]$ sudo easy_install sqlpython
Password:
Searching for sqlpython
Best match: sqlpython 1.7.1
Processing sqlpython-1.7.1-py2.6.egg
sqlpython 1.7.1 is already the active version in easy-install.pth
Installing sqlpython script to /usr/local/bin
Installing editplot_sqlpython script to /usr/local/bin

Using /Library/Python/2.6/site-packages/sqlpython-1.7.1-py2.6.egg
Processing dependencies for sqlpython
Finished processing dependencies for sqlpython


[me@MacBook software]$ echo $ORACLE_HOME
/Users/binneyd/software/oracle/instant_client
[me@MacBook software]$ echo $TNS_ADMIN
/Users/binneyd/software/oracle/network/admin
[me@MacBook software]$ echo $SQLPATH
/Users/binneyd/software/oracle/instant_client

</code>

I have tried a lot of variations but all ending up at the same place
so nor sure where to go from here since there is not real error
message?

cheers dave

On Mar 18, 4:35 am, Catherine Devlin <catherine.dev...@gmail.com>
wrote:

> > sqlpython+...@googlegroups.com<sqlpython%2Bunsubscribe@googlegroups .com>


> > .
> > For more options, visit this group at
> >http://groups.google.com/group/sqlpython?hl=en.
>
> --

> - Catherinehttp://catherinedevlin.blogspot.com/

donkeyx

unread,
Mar 20, 2010, 11:40:53 PM3/20/10
to sqlpython
I still have this error where i can connect via sqlplus but not using
sqlpython? I have all my env vars setup correctly so not sure where to
go from here.

> > Note that even though I have aconnectionfailure, the help message

> > There was no "Connectionfailure" message. There was no help message
> > displayed. But, there also was no validconnection. Any assistance or

William McVey

unread,
Mar 21, 2010, 12:27:36 PM3/21/10
to sqlp...@googlegroups.com, donkeyx
On Sat, Mar 20, 2010 at 8:11 AM, donkeyx <donke...@gmail.com> wrote:
> I am also running oracle but cannot connect and do not get any error
> message of the failure:

> [me@MacBook software]$ sqlplus $dbuser/$dbp...@test.worldSQL*Plus:

<snip>


> Connected to:
> Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit

> now with sqlpython :


> [me@MacBook software]$ sqlpython oracle://moodle:m00...@test.WORLD
> /bin/sh: xclip: command not found
> Connection failure.

It's hard to diagnose the problems since you go from using shell
environment variables in the sqlplus invocation to using the literal
username and password in the sqlpython invocation. Assuming your
dbuser is moodle and the pw is actually m00dl3, then the only other
thing I see that might explain the issue is that you go from trying to
connect to test.world to connecting to test.WORLD. Beyond the change
in capitalization, I've not seen an oracle database name with a dot in
it before, which leads me to believe the database is likely named
'test' and the '.world' is probably a schema or a connection
parameter. You may want to try specifying that as test/world with
sqlpython, e.g.:

$ sqlpython oracle://moodle:m00dl3@test/world

Hope this helps.

-- William

donkeyx

unread,
Mar 22, 2010, 7:46:38 AM3/22/10
to sqlpython
I think I have found the problem. It was missing the install of
cx_Oracle in the python libraries. I have never used python before and
it gave no errors about this not being present. Another thing to note
was that the cx_Oracle install will still look for the bin and lib
directories even though you have home and lib set in the env vars. So
to solve this i just added links in the client directory called bin
and lib which seems to fix that problem.

But now that i have connected it seems to never actually get the
metadata so i cannot use any of the nice features anyway ;( ??

On Mar 22, 2:27 am, William McVey <w...@wamber.net> wrote:

William McVey

unread,
Mar 22, 2010, 10:25:51 AM3/22/10
to sqlp...@googlegroups.com
On Mon, Mar 22, 2010 at 7:46 AM, donkeyx <donke...@gmail.com> wrote:
> But now that i have connected it seems to never actually get the
> metadata so i cannot use any of the nice features anyway ;( ??

It took a *long* time (over an hour) for the metadata to be retrieved
on my database as well using 1.7.1. I went ahead and cloned the source
repository so I could try older versions. Interestingly, in versions
1.5.0 and 1.6.0 (both of which appear to have used the cx_Oracle lib
as the main db backend) the 'ls' command got the metadata and
completed in under 10 seconds. I don't know if some pre-calculations
were happening on initial connect, but the entire session from
password entry to getting ls output was less than 5 minutes (probably
closer to 2). As soon as we cross into 1.7 land (where the backend was
replaced with gerald library), the time to retrieve and calculate the
metadata becomes crazy long.

-- William

P.S. Note that if you want to backrev to old versions of sqlpython,
you're going to need to remove your current versions of cmd2 and
install the version of cmd2 that was around at the time of the release
of sqlpython. Based on my testing, API differences between cmd2 are
such that the current version of cmd2 can't be used for old sqlpython.
For example, even though the setup.py for sqlpython 1.6.0 specifies
the needed version of the cmd2 library as 'cmd2>=0.4.7'. If you use
cmd2 0.6.1 with it, you'll get:
AttributeError: 'StubbornDict' object has no attribute 'sort'
Once you've removed the old cmd2, you can install a specific version
with 'pip install cmd2==0.4.7'

Catherine Devlin

unread,
Mar 24, 2010, 3:46:10 PM3/24/10
to sqlp...@googlegroups.com
On Mon, Mar 22, 2010 at 10:25 AM, William McVey <w...@wamber.net> wrote:
On Mon, Mar 22, 2010 at 7:46 AM, donkeyx <donke...@gmail.com> wrote:
> But now that i have connected it seems to never actually get the
> metadata so i cannot use any of the nice features anyway ;( ??

It took a *long* time (over an hour) for the metadata to be retrieved

Wow!  Really?  Mine was only about five minutes for a DBA-level user, and much less for a user account with only access to their own objects.  I wonder how many people are going to see painfully long retrieval times?

Anyway, sqlpython does cache the results to disk, so after the first session, you shouldn't have that wait again when using sqlpython from that machine (and as that user). 

Yes, pre-1.7, sqlpython was full of hard-coded calls to Oracle data dictionary views, which were much faster against large numbers of objects because they were only gathering the particular data the user was requesting at the moment.  That was useless, of course, for the cross-RDBMS tool everybody at PyCon was clamoring for.  Gerald builds a description of every object the user could ask about.  (OTOH, once that description is built, Gerald should be perfectly fast at providing the data.)

Hmm.  I don't know, offhand, how we can get tolerable speed and cross-platform access.  Maybe we can come up with a way to reach into Gerald for just the needed queries and run them live as needed, but that's just a first thought.  We'd need an even more intense level of accomodation from Gerald than Andy's already provided - perhaps if all the metadata query strings are accessible by name from outside the module, and return their results in a predictable way, Gerald could be made into a tool for on-the-fly cross-platform metadata querying as well as batch metadata gathering.  We'd have to send him some really awesome patches, and probably cupcakes.  :)
 
on my database as well using 1.7.1. I went ahead and cloned the source
repository so I could try older versions. Interestingly, in versions
1.5.0 and 1.6.0 (both of which appear to have used the cx_Oracle lib
as the main db backend) the 'ls' command got the metadata and
completed in under 10 seconds. I don't know if some pre-calculations
were happening on initial connect, but the entire session from
password entry to getting ls output was less than 5 minutes (probably
closer to 2). As soon as we cross into 1.7 land (where the backend was
replaced with gerald library), the time to retrieve and calculate the
metadata becomes crazy long.

 -- William

P.S. Note that if you want to backrev to old versions of sqlpython,
you're going to need to remove your current versions of cmd2 and
install the version of cmd2 that was around at the time of the release
of sqlpython. Based on my testing, API differences between cmd2 are
such that the current version of cmd2 can't be used for old sqlpython.
For example, even though the setup.py for sqlpython 1.6.0 specifies
the needed version of the cmd2 library as 'cmd2>=0.4.7'. If you use
cmd2 0.6.1 with it, you'll get:
  AttributeError: 'StubbornDict' object has no attribute 'sort'
Once you've removed the old cmd2, you can install a specific version
with 'pip install cmd2==0.4.7'

Mmm, I haven't even thought about trying to keep older sqlpython versions viable.  William, if you'd like rights on the repository and the PyPI site and would like to make changes for that, I'd be happy to hand you that responsibility.

--
- Catherine
Reply all
Reply to author
Forward
0 new messages