cx-oracle

Linux profile.d environment variables don't work with cx_oracle in Python

江枫思渺然 提交于 2020-02-07 07:56:36
问题 This is a bit of a continuation from my previous question: cx_Oracle does not recognize location of Oracle software installation for installation on Linux. After I was able to get cx_oracle installed properly, I wanted to set up my environment so the environment variables don't have to be exported every time. To do this, I wrote a shellscript that included these two export statements: export ORACLE_HOME=/home/user1/instantclient_12_1 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME And

execute a sql script file from cx_oracle?

◇◆丶佛笑我妖孽 提交于 2020-01-28 05:45:09
问题 Is there a way to execute a sql script file using cx_oracle in python. I need to execute my create table scripts in sql files. 回答1: PEP-249, which cx_oracle tries to be compliant with, doesn't really have a method like that. However, the process should be pretty straight forward. Pull the contents of the file into a string, split it on the ";" character, and then call .execute on each member of the resulting array. I'm assuming that the ";" character is only used to delimit the oracle SQL

cx_oracle Error handling issue

筅森魡賤 提交于 2020-01-25 06:55:08
问题 I'm trying to execute the following query in cx_Oracle but get the following error while executing: print 'Error.code =', error.code AttributeError: 'str' object has no attribute 'code' Code: try: conn.exec("Select * from table1") except cx_Oracle.DatabaseError, ex: error, = ex.args print 'Error Inserting Field Base' print 'Error.code =', error.code print 'Error.message =', error.message print 'Error.offset =', error.offset conn.rollback() 回答1: I think this is a better way to do it. I am not

cx_oracle Error handling issue

♀尐吖头ヾ 提交于 2020-01-25 06:55:05
问题 I'm trying to execute the following query in cx_Oracle but get the following error while executing: print 'Error.code =', error.code AttributeError: 'str' object has no attribute 'code' Code: try: conn.exec("Select * from table1") except cx_Oracle.DatabaseError, ex: error, = ex.args print 'Error Inserting Field Base' print 'Error.code =', error.code print 'Error.message =', error.message print 'Error.offset =', error.offset conn.rollback() 回答1: I think this is a better way to do it. I am not

Python Oracle DB Connect without Oracle Client

给你一囗甜甜゛ 提交于 2020-01-25 06:51:12
问题 I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine. Is it possible to connect to oracle DB in Python without installing the oracle client in the local machine where the python application will be stored and executed? Like in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python. Any help is appreciated Installing oracle client

Return variable from cx_Oracle PL/SQL call in Python

落爺英雄遲暮 提交于 2020-01-20 05:57:08
问题 I want to execute an Oracle PL/SQL statement via cx_oracle in Python. Code looks like this: db = cx_Oracle.connect(user, pass, dsn_tns) cursor = db.cursor() ... sel = """ DECLARE c NUMBER := 0.2; mn NUMBER := 1.5; res NUMBER; BEGIN res := c+mn/6.; END; """ try: cursor.execute(sel) print "PL/SQL successful executed ..." except cx_Oracle.DatabaseError as e: err, = e.args print "\n".join([str(err.code),err.message,err.context]) The code is running without problems, but is there any chance to get

cx_oracle is installed still python gives an import error

陌路散爱 提交于 2020-01-16 16:52:00
问题 I have been having a hard time with this. I have the cx_oracle file installed:cx_Oracle-5.3-12c.win-amd64-py3.6-2 Earlier I had Python 3.6.4 and this cx_oracle file was not getting installed,Then I removed that version of python installed python 3.6 and then the cx_oracle file got installed successfully. But now that I am trying to import cx_oracle from python it is not working. Why? I am using Windows 10. All my python executables and cx_oracle and oracle11g files are on the disk partition E

cx_oracle is installed still python gives an import error

二次信任 提交于 2020-01-16 16:50:58
问题 I have been having a hard time with this. I have the cx_oracle file installed:cx_Oracle-5.3-12c.win-amd64-py3.6-2 Earlier I had Python 3.6.4 and this cx_oracle file was not getting installed,Then I removed that version of python installed python 3.6 and then the cx_oracle file got installed successfully. But now that I am trying to import cx_oracle from python it is not working. Why? I am using Windows 10. All my python executables and cx_oracle and oracle11g files are on the disk partition E

Get column value by name rather than position in cx_Oracle

戏子无情 提交于 2020-01-15 12:15:28
问题 Using cx_Oracle , I am selecting data from an Oracle database. curs = cxn.cursor() result = curs.execute(SELECT FirstName, LastName FROM Person) Is there a way to return only the firstname without numerical index? For example: for row in result: result[0] #will return the first column What I am hoping to do is call the value like result['FirstName'] 回答1: You can use a row factory to return a row that responds to names in addition to indices. One simple way to do that is using collections

Calling Python from Oracle

为君一笑 提交于 2020-01-13 02:30:10
问题 Is it possible to call Python within an Oracle procedure? I've read plenty of literature about the reverse case (calling Oracle SQL from Python), but not the other way around. What I would like to do is to have Oracle produce a database table, then I would like to call Python and pass this database table to it in a DataFrame so that I could use Python to do something to it and produce results. I might need to call Python several times during the Oracle procedure. Does anyone know if this is