cx-oracle

cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files

孤者浪人 提交于 2019-12-03 09:53:35
I need install cx_Oracle for Python 2.5 on Linux (Linux 2.6.18-371.1.2.el5 i686). I have installed Oracle client 10.2.0.4. I have tried following: 1. Download cx_Oracle tar.gz from http://sourceforge.net/projects/cx-oracle/files/ . I don't know which of listed version are suitable for python 2.5 and Oracle client 10.2.0.4, so try cx_Oracle-5.1.tar.gz. Unpacked tar, go to unpacked folder and run python setup.py install. I got error: Traceback (most recent call last): File "setup.py", line 187, in <module> raise DistutilsSetupError("cannot locate Oracle include files") distutils.errors

How can I make cx-oracle bind the results of a query to a dictionary rather than a tuple?

断了今生、忘了曾经 提交于 2019-12-03 05:59:16
问题 Here is my code. I would like to find a way to have results from a query returned as a list of dictionaries rather than list of tuples. It seems like cx_oracle supports this with parts of the documentation talking about 'binding'. Though I can't figure out how it works. def connect(): dsn = cx_Oracle.makedsn("host", 1521, "sid") orcl = cx_Oracle.connect('scott/tiger@' + dsn) curs = orcl.cursor() sql = "select * from sometable" curs.execute(sql) result = curs.fetchall() for row in result:

cx_Oracle with Windows authentication

不打扰是莪最后的温柔 提交于 2019-12-02 23:43:24
问题 I would like to make cx_Oracle work with Windows OS authentication but fail miserably: I know that with pyodbc you can make it work using trusted_connection='yes' but I have to make use of the Oracle client (11g/12c), which does not seem to go well in hand with pyodbc. The closest to what I need seems to be the use of Wallets. However, duplicating existing information does not seem like the way to go. There is mention of external authentication in the cx_Oracle 5.2.1 release notes but this

How can I make cx-oracle bind the results of a query to a dictionary rather than a tuple?

本秂侑毒 提交于 2019-12-02 19:24:19
Here is my code. I would like to find a way to have results from a query returned as a list of dictionaries rather than list of tuples. It seems like cx_oracle supports this with parts of the documentation talking about 'binding'. Though I can't figure out how it works. def connect(): dsn = cx_Oracle.makedsn("host", 1521, "sid") orcl = cx_Oracle.connect('scott/tiger@' + dsn) curs = orcl.cursor() sql = "select * from sometable" curs.execute(sql) result = curs.fetchall() for row in result: print row[13] #CATEGORY field order print row['CATEGORY'] # <- I want this to work ('CATEGORY' is the name

memoryError when connect() with a engine created by create_engine from sqlalchemy in flask

心不动则不痛 提交于 2019-12-02 09:34:18
I want to access an oracle database through sqlalchemy in flask development. An engine is created by sqlalchemy create_engine() MemoryError is reported when engine.connect() is called. If setting a wrong password in the linkword, it would report: sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) ORA-01017: invalid username/password; logon denied. With the correct password and user name, MemoryError would appear. It is very strange when i copy the codes into jupyter or a new project (not a flask project)in pycharm, the codes work well. I wonder if it is possible the flask has problems.

Python - TypeError: expecting string or bytes object

£可爱£侵袭症+ 提交于 2019-12-02 05:10:49
问题 After much research I cannot figure out why I receive this error in my code. I'm trying to export a Pandas Dataframe to my Oracle table. I have successfully done this hundreds of times on other data tables but this one keeps producing errors. Here is my Dataframe, which I read in with pd.read_excel and appended three of my own columns with simple df['column_name'] = variable commands: S USTAINABLE H ARVEST S ECTOR| QUOTA LISTING APRIL 16 2013 Unnamed: 1 \ 1 DATE TRADE ID 2 04/02/13 130014 3 0

INSERT not working in cx_oracle when used with execute. How to get it working?

喜你入骨 提交于 2019-12-02 02:57:22
I am new to cx_oracle. I have established a connection and I am able to create and drop a table using execute. Where I am failing is when I try to use "INSERT INTO ..." in execute. It doesn't show any error but it doesn't store any value either (I confirmed this by checking if the entry had taken place using sqlplus from shell). The code I used was: table_name = "T1" column = "D" insert_value = "test value" sqlcode = "INSERT INTO "+table_name+" ("+column+") VALUES ('"+insert_value+"')" cursor.execute(sqlcode) Please help me, any help would be appreciated. Thanks in advance. J Venu Murthy How

Python - TypeError: expecting string or bytes object

时光怂恿深爱的人放手 提交于 2019-12-02 01:45:09
After much research I cannot figure out why I receive this error in my code. I'm trying to export a Pandas Dataframe to my Oracle table. I have successfully done this hundreds of times on other data tables but this one keeps producing errors. Here is my Dataframe, which I read in with pd.read_excel and appended three of my own columns with simple df['column_name'] = variable commands: S USTAINABLE H ARVEST S ECTOR| QUOTA LISTING APRIL 16 2013 Unnamed: 1 \ 1 DATE TRADE ID 2 04/02/13 130014 3 0 0 4 0 0 5 0 0 6 FY13 QUOTA – TO BUY 0 7 DATE TRADE ID 8 3/26/13 130006 9 4/9/13 130012 10 3/26/13

AWS Python Lambda with Oracle - OID Generation Failed

跟風遠走 提交于 2019-12-01 20:08:03
I'm trying to connect to an Oracle DB using AWS Lambda Python code. My code is below: import sys, os import cx_Oracle import traceback def main_handler(event, context): # Enter your database connection details here host = "server_ip_or_name" port = 1521 sid = "server_sid" username = "myusername" password = "mypassword" try: dsn = cx_Oracle.makedsn(host, port, sid) print dsn connection = cx_Oracle.Connection("%s/%s@%s" % (username, password, dsn)) cursor = connection.cursor() cursor.execute("select 1 / 0 from dual") except cx_Oracle.DatabaseError, exc: error, = exc.args print >> sys.stderr,

python cx oracle expecting string, unicode or buffer object

喜夏-厌秋 提交于 2019-12-01 14:38:06
I am trying to run following code snippet in python to connect to oracle, but constantly running into following error. I have tried a lot of combinations but it doesn't seem to work. I understand the error, but don't understand what is incompatible here. Has anyone come across this issue? How do I fix it? File "", line 1, in File "/workplace/applications/python2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1613, in execute connection = self.contextual_connect(close_with_result=True) File "/workplace/applications/python2.7/lib/python2.7/site-packages/sqlalchemy/engine/base.py"