cx-oracle

cx_Oracle with multiple Oracle client versions

淺唱寂寞╮ 提交于 2019-12-11 06:31:55
问题 I am running Python 2.7 and am using cx_Oracle on a linux 64 bit OS. I need to be able to run against either an 11.2 or 12.1 Oracle client since I can't be sure which client will be installed on the deployed target. I know there are cx_Oracle built against each Oracle client. How can I be sure that the app will work? I should mention I am using pyinstaller to package up the application. Is there a version of cx_Oracle the is built against both Oracle clients or am I required to have two

Binding variable to table name with cx_Oracle

折月煮酒 提交于 2019-12-11 05:33:33
问题 I'm using cx_Oracle in Python and can't get a variable be used as table name, like in this simple example: query = "select * from some.:usertable.userinfo" bindvars = {'usertable':usertable} cursor.execute(query, bindvars) What is the correct syntax? Variable substition works fine when I use WHERE … etc. but not with table names. I guess I have to separate ":usertable" somehow… 回答1: Database adapters rarely support using parameters for anything that isn't a 'value' (something that needs

cx_Oracle CREATE TABLE AS returns ORA-01036: illegal variable name/number

时光毁灭记忆、已成空白 提交于 2019-12-11 05:17:18
问题 I'm trying to CREATE TABLE AS using cx_Oracle on Python 2.4.6 The following code: query = '''CREATE TABLE TMP_STATS_1 AS select NUM from INF_CARD where IMPORT_DATE between to_date(:datepass || ' 00:00:00','dd/mm/yyyy hh24:mi:ss') and to_date(:datepass || ' 23:59:59','dd/mm/yyyy hh24:mi:ss')''' curs.execute(query, datepass=datep) Returns: cx_Oracle.DatabaseError: ORA-01036: illegal variable name/number Taking out the CREATE TABLE TMP_STATS_1 AS and leaving only the SELECT statement, works

cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle in linux

拥有回忆 提交于 2019-12-11 05:06:49
问题 I am trying to connect to database using cx_Oracle module i am getting below error server_IP = ipaddress:1221/xyz try: db = cx_Oracle.connect('username', 'password', server_IP) print db except cx_Oracle.DatabaseError as e: error, = e.args if error.code == 1017: print('Please check your credentials.') else: print('Database connection error: %s'.format(e)) raise cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle My question do i need to install any oracle client in linux or

cx_Oracle error. DPI-1047: Cannot locate a 64-bit Oracle Client library

爷,独闯天下 提交于 2019-12-11 00:35:06
问题 I installed the library and when trying to access SQL in jupyter notebook with my credentials the following error appears: DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help 回答1: Probably you have installed cx_Oracle Python library. In order to execute the DB connectivity through jupyter notebook, you need to install the Oracle Client and that is what missing

Python/Oracle/cx_Oracle date behavior with year=0 issues

蓝咒 提交于 2019-12-10 22:32:37
问题 I'm currently working on some ETL code to incrementally load data from a source Oracle system to a Postgresql analysis environment with Python as the glue. I am leveraging cx_Oracle as the driver to pull the Oracle data, but I am running into some strange issues with Oracle Date and Python datetime and year 0. As far as I understand, neither Oracle nor Python support year 0. I've isolated a particular row and field with an offending Date: SELECT CAR_RENTAL_DATE, EXTRACT(YEAR FROM CAR_RENTAL

error when connecting oracle in python using cx_Oracle

こ雲淡風輕ζ 提交于 2019-12-10 21:41:52
问题 I was trying to connect oracle database using python like below. import cx_Oracle conn = cx_Oracle.connect('user/password@host:port/database') I've faced an error when connecting oracle. DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help. I've been struggling to figure it out. I used my user name, password, host, port and

Problem with SELECT from database if using unicode character

淺唱寂寞╮ 提交于 2019-12-10 20:44:07
问题 I'm using latest version of python and robot framework with DatabaseLibrary (https://franz-see.github.io/Robotframework-Database-Library/api/1.0.1/DatabaseLibrary.html) And I have problem with SELECT from database when I try using Unicode character like this: select * from labcamprodfull where PRODUCTNAME like '% ščť %' Then I execute/run test and i get this error: UnicodeEncodeError: 'ascii' codec can't encode character '\xae' in position 54: ordinal not in range(128) Here is my code: ***

ocx_Oracle ORA-12541 tns no listener

本小妞迷上赌 提交于 2019-12-10 19:16:18
问题 I try to connect to a remote oracle server by cx_Oracle: db = cx_Oracle.connect('username', 'password', dsn_tns) but it says databaseError: ORA-12541 tns no listener 回答1: This error may occur if the listener.ora file (on the Oracle server itself) is configured to listen for "localhost" instead of the machine name. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = WN700014 )(PORT = 1521)) ) ) See this post. 回答2: I

Parse SQL file with PL/SQL and DML/DDL using cx_Oracle in python

梦想与她 提交于 2019-12-10 13:44:57
问题 I have an SQL file which I want to parse and execute in oracle using cx_Oracle python library. The SQL file contains both classic DML/DDL and PL/SQL, eg. it can look like this: create.sql : -- This is some ; malicious comment CREATE TABLE FOO(id numeric); BEGIN INSERT INTO FOO VALUES(1); INSERT INTO FOO VALUES(2); INSERT INTO FOO VALUES(3); END; / CREATE TABLE BAR(id numeric); if I use this file in SQLDeveloper or SQL*Plus, it will be split into 3 queries and executed. However, cx_Oracle