cx-oracle

easy_install cx_Oracle (python package) on Windows

佐手、 提交于 2019-11-27 22:56:56
So I found Help installing cx_Oracle but am still stuck. I downloaded the latest instantclient from oracle, and set ORACLE_HOME to the location of the extracted files (both direct and with a bin folder between the ORACLE_HOME value and the files), but easy_install is popping an error when running setup.py saying it can't locate the Oracle include files. I did notice that only the 11g dll is in the folder, do I need all 3 drivers present for setup to complete? If so, where do I even get them? Christian Witts Honestly it is a hell of a lot easier to install cx_Oracle from one of the binary

cx_Oracle: ImportError: DLL load failed: This application has failed

霸气de小男生 提交于 2019-11-27 22:10:08
Here's what I did: I'm on Windows XP SP3 I already had Python 2.7.1 installed. I downloaded instantclient-basic-nt-11.2.0.3.0.zip , unzipped it, and put it in C:\Program Files\Oracle\instantclient_11_2 . I added this path to the Windows Path environment variable. I created a new environment variable ORACLE_HOME holding this path as its value. I installed cx_Oracle-5.1.2-11g.win32-py2.7.msi . And on running import cx_Oracle all I get is Traceback (most recent call last): File "<string>", line 2, in <module> ImportError: DLL load failed: This application has failed to start because the

Set database connection timeout in Python

被刻印的时光 ゝ 提交于 2019-11-27 17:54:59
问题 I'm creating a RESTful API which needs to access the database. I'm using Restish, Oracle, and SQLAlchemy. However, I'll try to frame my question as generically as possible, without taking Restish or other web APIs into account. I would like to be able to set a timeout for a connection executing a query. This is to ensure that long running queries are abandoned, and the connection discarded (or recycled). This query timeout can be a global value, meaning, I don't need to change it per query or

How can I access Oracle from Python?

元气小坏坏 提交于 2019-11-27 17:43:32
How can I access Oracle from Python? I have downloaded a cx_Oracle msi installer, but Python can't import the library. I get the following error: import cx_Oracle Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import cx_Oracle ImportError: DLL load failed: The specified module could not be found. I will be grateful for any help. Here's what worked for me. My Python and Oracle versions are slightly different from yours, but the same approach should apply. Just make sure the cx_Oracle binary installer version matches your Oracle client and Python versions. My versions

How can I do a batch insert into an Oracle database using Python?

删除回忆录丶 提交于 2019-11-27 14:04:57
I have some monthly weather data that I want to insert into an Oracle database table but I want to insert the corresponding records in a batch in order to be more efficient. Can anyone advise as to how I'd go about doing this in Python? For example let's say my table has four fields: a station ID, a date, and two value fields. The records are uniquely identified by the station ID and date fields (composite key). The values I'll have to insert for each station will be kept in a list with X number of full years worth of data, so for example if there are two years of values then the value lists

Help installing cx_Oracle

て烟熏妆下的殇ゞ 提交于 2019-11-27 12:12:33
问题 I'm trying to install the cx_Oracle for Python 2.6, but it is failing. I don't know enough about C or MS Vis. Studio's compiler to even approach fixing it myself. This is what is output on the command line: C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install running install running build running build_ext building 'cx_Oracle' extension C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Oracle\instantclient\sdk\include -IC:\p ython26

Python cx_Oracle bind variables

一笑奈何 提交于 2019-11-27 08:42:47
I am a Python newbie, I am having troubles in the use of bind variables. If I execute the code below everything works fine. bind= {"var" : "ciao"} sql = "select * from sometable where somefield = :bind" cur.prepare(sql) cur.execute(sql,bind) Instead if I add another bind variable I obtain an error. bind= {"var" : "ciao"} sql = "select * from sometable where somefield = :bind and otherfield = :bind" cur.prepare(sql) cur.execute(sql,(bind,bind)) cur.execute(sql,(bind,bind)) Oracle.NotSupportedError: Variable_TypeByValue(): unhandled data I have solved it with cur.execute(sql,(bind["var"],bind[

cx_Oracle & Connecting to Oracle DB Remotely

有些话、适合烂在心里 提交于 2019-11-27 00:28:11
How do you connect to a remote server via IP address in the manner that TOAD, SqlDeveloper, are able to connect to databases with just the ip address, username, SID and password? Whenever I try to specify and IP address, it seems to be taking it locally. In other words, how should the string for cx_Oracle.connect() be formatted to a non local database? There was a previous post which listed as an answer connecting to Oracle via cx_Oracle module with the following code: #!/usr/bin/python import cx_Oracle connstr='scott/tiger' conn = cx_Oracle.connect(connstr) curs = conn.cursor() curs.execute(

Why the need to commit explicitly when doing an UPDATE?

天大地大妈咪最大 提交于 2019-11-26 23:36:44
问题 Here's my code: import cx_Oracle conn = cx_Oracle.connect(usr, pwd, url) cursor = conn.cursor() cursor.execute("UPDATE SO SET STATUS='PE' WHERE ID='100'") conn.commit() If I remove the conn.commit() , the table isn't updated. But for select statements, I don't need that conn.commit() . I'm curious why? 回答1: The DB-API spec requires that connecting to the database begins a new transaction, by default. You must commit to confirm any changes you make, or rollback to discard them. Note that if

How can I access Oracle from Python?

北城以北 提交于 2019-11-26 22:36:26
问题 How can I access Oracle from Python? I have downloaded a cx_Oracle msi installer, but Python can't import the library. I get the following error: import cx_Oracle Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import cx_Oracle ImportError: DLL load failed: The specified module could not be found. I will be grateful for any help. 回答1: Here's what worked for me. My Python and Oracle versions are slightly different from yours, but the same approach should apply. Just