cx-oracle

DatabaseError: ORA-01036: illegal variable name/number

北慕城南 提交于 2019-11-29 21:00:44
问题 I need to substitute the following values into select query. but i got the error as i mentioned below self.jobNo = J-12060 qcActivity = C173 self.wrkArea = 1666339 cursor.execute("""SELECT A.MARKERID, D.COMMENTS,A.STATUS,A.X1,A.Y1,A.X2,A.Y2,C.ERRGROUP,C.ERRDESC,c.category FROM MDP_ERR_MASTER A,(SELECT MARKERID, MAX(RECNO) maxRECNO FROM MDP_ERR_MASTER where project_code = ':jobno' and errorcode like ':jobno_:qcActivity%' AND WORKAREA LIKE ':workarea%' GROUP BY MARKERID) B,MDP_ERR_CONFIG C,

How do I read cx_Oracle.LOB data in Python?

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:40:15
问题 I have this code: dsn = cx_Oracle.makedsn(hostname, port, sid) orcl = cx_Oracle.connect(username + '/' + password + '@' + dsn) curs = orcl.cursor() sql = "select TEMPLATE from my_table where id ='6'" curs.execute(sql) rows = curs.fetchall() print rows template = rows[0][0] orcl.close() print template.read() When I do print rows , I get this: [(<cx_Oracle.LOB object at 0x0000000001D49990>,)] However, when I do print template.read() , I get this error: cx_Oracle.DatabaseError: Invalid handle!

Deploying cx_Oracle in Windows

流过昼夜 提交于 2019-11-29 11:35:33
I'm trying to use cx_Oracle module in python to access a remote database and insert or delete rows in tables. BTW I have downloaded oracle instant client 11.1 and also odbc and sqlplus versions. I have set environment variables ORACLE_HOME and TNS_ADMIN to directory I have unzipped files there and add this this directory to the PATH variable. As I googled I think there should be some .ora files but I can't find them. I can use sqlplus commands from command line, but my main problem is that I can't install and use cx_Oracle . I don't want to use any command line scripts; I just want to use cx

Return variable from cx_Oracle PL/SQL call in Python

偶尔善良 提交于 2019-11-29 10:27:53
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 the result back to Python? You can bind input and output variables to the block like so. import cx

Issue building cx_Oracle - libclntsh.so.11.1 => not found

对着背影说爱祢 提交于 2019-11-29 05:08:01
问题 I'm trying to build cx_Oracle for a Python 2.7.2 and Oracle 11g installation but the built cx_Oracle.so cannot find libclntsh.so.11.1 so importing cx_Oracle in Python fails. /mypath/cx_Oracle-5.1.1/build/lib.linux-x86_64-2.7-11g]$ ldd cx_Oracle.so libclntsh.so.11.1 => not found libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ae9be290000) libc.so.6 => /lib64/libc.so.6 (0x00002ae9be4ab000) /lib64/ld-linux-x86-64.so.2 (0x000000389b600000) I have libclntsh.so.11.1 in my Oracle client

Set database connection timeout in Python

寵の児 提交于 2019-11-29 03:50:54
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 connection creation. Given the following code: import cx_Oracle import sqlalchemy.pool as pool conn

Help installing cx_Oracle

陌路散爱 提交于 2019-11-28 19:20:44
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\include -IC:\python26\PC /Tccx_Oracle.c /Fobuild\temp.win32-2.6-11g\Release\cx_Oracle.obj -DBUILD

cx_Oracle and Exception Handling - Good practices?

孤街醉人 提交于 2019-11-28 19:03:09
问题 I'm trying to use cx_Oracle to connect to an Oracle instance and execute some DDL statements: db = None try: db = cx_Oracle.connect('username', 'password', 'hostname:port/SERVICENAME') #print(db.version) except cx_Oracle.DatabaseError as e: error, = e.args if error.code == 1017: print('Please check your credentials.') # sys.exit()? else: print('Database connection error: %s'.format(e)) cursor = db.cursor() try: cursor.execute(ddl_statements) except cx_Oracle.DatabaseError as e: error, = e

cx_Oracle doesn't connect when using SID instead of service name on connection string

折月煮酒 提交于 2019-11-28 18:15:10
I have a connection string that looks like this con_str = "myuser/mypass@oracle.sub.example.com:1521/ora1" Where ora1 is the SID of my database. Using this information in SQL Developer works fine, meaning that I can connect and query without problems. However, if I attempt to connect to Oracle using this string, it fails. cx_Oracle.connect(con_str) DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor This connection string format works if the ora1 is a service name, though. I have seen other questions that seem to have the reverse of my

Deploying cx_Oracle in Windows

半城伤御伤魂 提交于 2019-11-28 05:28:15
问题 I'm trying to use cx_Oracle module in python to access a remote database and insert or delete rows in tables. BTW I have downloaded oracle instant client 11.1 and also odbc and sqlplus versions. I have set environment variables ORACLE_HOME and TNS_ADMIN to directory I have unzipped files there and add this this directory to the PATH variable. As I googled I think there should be some .ora files but I can't find them. I can use sqlplus commands from command line, but my main problem is that I