In cx_Oracle (or Oracle in general), is it possible to allocate a cursor for each query, or to reuse a cursor across several queries.
def getSomeData(curs): # case 1: pass in a cursor, which is generally
curs.execute('select ...') # reused across queries
return curs.fetchall()
def getSomeData(conn): # ca...
Hi all,
What is the behavior of cx_Oracle cursors when the connection object is used by different threads? How would generators affect this behavior? Specifically...
Edit: The original example function was incorrect; a generator was being returned by a sub function, yield wasn't used directly in the loop. This clarifies when finally...
Hi,
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 lo...
I'm trying to do this again an Oracle 10 database:
cursor = connection.cursor()
lOutput = cursor.var(cx_Oracle.STRING)
cursor.execute("""
BEGIN
%(out)s := 'N';
END;""",
{'out' : lOutput})
print lOutput.value
but I'm getting
DatabaseError: ORA-01036: illegal variable name/number
Is...
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?
...
I've downloaded cx_oracle some time ago and wrote a script to convert data to XML. I've had to reisntall my OS and grabbed the latest version of cx_Oracle (5.0.3) and all of the sudden my code is broken.
The first thing was that cx_Oracle.connect wanted unicode rather string for the username and password, that was very easy to fix. But ...
Found an example using cx_Oracle, this example shows all the information of Cursor.description.
import cx_Oracle
from pprint import pprint
connection = cx_Oracle.Connection("%s/%s@%s" % (dbuser, dbpasswd, oracle_sid))
cursor = cx_Oracle.Cursor(connection)
sql = "SELECT * FROM your_table"
cursor.execute(sql)
data = cursor.fetchall()
p...
This could be very basic question. I'd like to validate a variable is type of cx_Oracle.OracleCursor, so I tried a couple of trials but all failed:
import cx_Oracle
def execute_sql(cursor):
"""Execute a SQL using cursor(cx_Oracle.OracleCursor)."""
if not cursor:
logging.error('cursor is null.')
return None # TO...
i have the following:
ora_wet = oracle_connection()
cursor = ora_wet.cursor()
sqlQuery = u"SELECT * FROM web_cities WHERE cty_name = 'София'"
cursor.execute(sqlQuery)
sqlResult = cursor.fetchone()
When I do this I get a TypeError: expecting None or a string on line 18 which is the cursor.execute(sqlQuery)
If I make the query non-uni...
I am trying to run python in an Apache WS in a linux RHEL x86_64.
After Install and configure Python2.5 and Apache, I install Oracle Instant Client (basic and sdk) in a by an .rpm file withou any problem.
oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm
oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm
I set the envoirment variables
...
I have some small python apps that use cx_Oracle to connect to an Oracle database. I deploy these apps by compiling them with py2exe, which works fine in many cases.
The problem is, there is no standard Oracle Client version (9i and 10g for example) across the many people who need to install this, and it would be very frustrating to try...
Hello,
We need to bulk load many long strings (>4000 Bytes, but <10,000 Bytes) using cx_Oracle. The data type in the table is CLOB. We will need to load >100 million of these strings. Doing this one by one would suck. Doing it in a bulk fashion, ie using cursor.arrayvar() would be ideal. However, CLOB does not support arrays. BLOB, LOB,...
Hi guys,
so here it is: I'm trying to use the cx_Oracle to access Oracle10g XE database.
everything goes ok if i'm invoking python via the shell terminal then use the cx_Oracle module in a command line manner (import, db access and querying).
However,I face some problems with Eclipse. There in no comment in the import line where I im...
I'm trying to fetch some data from a column whose DATA_TYPE=NUMBER(1,0) with this piece of code:
import cx_Oracle
conn = cx_Oracle.connect(usr, pwd, url)
cursor = conn.cursor()
cursor.execute("SELECT DELETED FROM SERVICEORDER WHERE ORDERID='TEST'")
print(cursor.fetchone()[0])
which complains thus:
Traceback (most recent call last):
...
Hi
I'm trying to load cx_Oracle using tomcat.
Loading from python works fine, but for jython I'm getting "module not found". My system.path includes site-packages that contains cx_Oracle.so.
I'm new to jython and I've not had time to familiarize myself with all the variables but I believe I have all the necessary environment variables...
Here more or less is my Python code.
import cx_Oracle
conn = cx_Oracle.connect( "...")
cursor = conn.cursor()
cursor.execute( "SELECT * FROM test_table" )
row = cursor.fetchone():
for col in row:
print type( col )
if isinstance( col, cx_Oracle.OBJECT):
print "true"
If the underlying column in Oracle is of type GEOMETRY, the ...