python cx_oracle and server information
Asked Answered
P

2

7

In order to demonstrate the security feature of Oracle one has to call OCIServerVersion() or OCIServerRelease() when the user session has not yet been established.

While having the database parameter sec_return_server_release_banner = false. I am using Python cx_Oracle module for this, but I am not sure how to get the server version before establishing the connection. Any ideas?

Pedestrian answered 22/2, 2012 at 5:8 Comment(5)
cxOracle does not use OCI functions to get version but calls dbms_utility.db_version after connection so I think you can't without an user that has execute permission on dbms_utility.db_version procedure, you can try bypassing cxoracle by playing directly with OCI client using ctypes (cxoracle on pypy uses ctypes)Talus
the connect function is Connection_Connect in Connection.c it calls OCIServerAttach() but there are no ways to call something else before authTalus
bitbucket.org/pypy/pypy/src/default/pypy/module/oracle/… it's rpython you should call OCIServerVersion() after serverattach, but I don't known how easy can be ported to cpython+ctypesTalus
Am not sure about your usecase, but have you tried using zxJDBC?' from com.ziclix.python.sql import zxJDBC'Oedipus
@jhon.smith: Are you still looking to have this answered? If the other suggestions above did not help, it would not be very difficult to add this capability to cx_Oracle. If you still need this, I'm sure we can help you add this functionality.Amenity
P
0

Depends on your SW architecture and your intention to be cross platform ready.

cx_Oracle is dependent on Oracle client. So you are sure that there is Oracle client on known path. Even through you don't want to use Oracle client for regular session you could use it for preliminary check of the server.

On linux/unix you could run in subprocess following code:

sqlplus user/pasword@INSTANCE <<< "quit"| grep "Oracle Database"| head -n 1 

Grep and other processing could be done in your code and in Windows it is necessary. By the code you will get version of Oracle and you will know if the connection info is correct.

Promptbook answered 25/1, 2013 at 14:39 Comment(1)
This assumes that sqlplus is installed. Oracle Instantclient (which just provides OCI and is therefore sufficient by itself for cxOracle) doesn't come by default with sqlplus.Tyner
O
0

With-out establishing a connection,. No you can never asking anything. It's like going to Google Page.(Internet Architecture - wether you call it sessionless or session based)

As for Authentical, if no permission are set - Oracle uses a username 'nobody' as a user and thus gives every user a session.

I am a user of Oracle APEX, and I use Python, PLSQL regurlary.

That's one nice question. Thanks.

Obstruct answered 16/1, 2014 at 6:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.