cx-oracle

How to fix: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library - Python

谁说胖子不能爱 提交于 2020-06-22 13:47:30
问题 I am establishing a connection to oracle 11g which is in a remote server using cx_oracle 7 with python 3.6.7. my OS in Ubuntu 18.04 I have installed oracle instant client library with libclntsh.so but I am not getting the expected output. here is the code which i am using to connect to the oracle db connection = cx_Oracle.connect("username/password@host/port") print (connection.version) connection.close() when the script runs i expect to get the connection version instead i am getting the

Binding variables to SQLAlchemy query for Pandas.read_sql

只谈情不闲聊 提交于 2020-06-01 05:57:18
问题 Is it possible to bind variables to a SQLAlchemy query used in a Pandas.read_sql statement? Using %s in the WHERE clause does not work and the documentation for cx_Oracle states: cursor.execute('SELECT * FROM employees WHERE department_id=:dept_id) Using the cx_Oracle driver directly is deprecated in Pandas and is not a viable option. I have a list of groups I need to iterate through the WHERE statement as SELECT * is too large in memory to handle on a single PC. EXAMPLE: SELECT * FROM DUAL

Python - sqlalchemy - oracle connection fails to connect to SID

為{幸葍}努か 提交于 2020-04-30 05:45:54
问题 I am trying to use sqlalchemy to connect to an oracle DB. I was expecting the following to work given that it appears the exact syntax is shown in the sqlalchemy documentation. oracle_db = sqlalchemy.create_engine('oracle://user:pass@server:1521/dev') but this results in the error: dsn = self.dbapi.makedsn(url.host, port, **makedsn_kwargs) TypeError: makedsn() takes no keyword arguments The following call initially works without the service name oracle_db = sqlalchemy.create_engine('oracle:/

How to write pandas dataframe to oracle database using to_sql?

て烟熏妆下的殇ゞ 提交于 2020-02-26 18:36:11
问题 I'm a new oracle learner. I'm trying to write a pandas dataframe into an oracle table. After I have made research online, I found the code itself is very simple, but I don't know why my code doesn't work. I have read the pandas dataframe from my local file: import cx_Oracle import pandas as pd import os dir_path = os.path.dirname(os.path.realpath("__file__")) df = pd.read_csv(dir_path+"/sample.csv") Now print df, the dataframe df shold be like this: DATE YEAR MONTH SOURCE DESTINATION 0 11/1

How to write pandas dataframe to oracle database using to_sql?

偶尔善良 提交于 2020-02-26 18:35:57
问题 I'm a new oracle learner. I'm trying to write a pandas dataframe into an oracle table. After I have made research online, I found the code itself is very simple, but I don't know why my code doesn't work. I have read the pandas dataframe from my local file: import cx_Oracle import pandas as pd import os dir_path = os.path.dirname(os.path.realpath("__file__")) df = pd.read_csv(dir_path+"/sample.csv") Now print df, the dataframe df shold be like this: DATE YEAR MONTH SOURCE DESTINATION 0 11/1

How to write pandas dataframe to oracle database using to_sql?

廉价感情. 提交于 2020-02-26 18:34:46
问题 I'm a new oracle learner. I'm trying to write a pandas dataframe into an oracle table. After I have made research online, I found the code itself is very simple, but I don't know why my code doesn't work. I have read the pandas dataframe from my local file: import cx_Oracle import pandas as pd import os dir_path = os.path.dirname(os.path.realpath("__file__")) df = pd.read_csv(dir_path+"/sample.csv") Now print df, the dataframe df shold be like this: DATE YEAR MONTH SOURCE DESTINATION 0 11/1

Better ways to print out column names when using cx_Oracle

十年热恋 提交于 2020-02-26 06:36:05
问题 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() print "(name, type_code, display_size, internal_size, precision, scale, null_ok)" pprint(cursor.description) pprint(data) cursor.close() connection.close() What I

How to connect to Oracle-RAC using SCAN in python?

北城余情 提交于 2020-02-25 13:15:54
问题 I use cx_Oracle module to connect to standalone Oracle server as follows import cx_Oracle CONN_INFO = { 'host': 'xxx.xx.xxx.x', 'port': 12345, 'user': 'user_name', 'psw': 'your_password', 'service': 'abc.xyz.com', } CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO) connection = cx_Oracle.connect(CONN_STR) but as scan IP doesn not have machine and its own username passoword, How do we connect? 回答1: Es described in the documentation, you can simple use the name defined in

How to connect to Oracle-RAC using SCAN in python?

柔情痞子 提交于 2020-02-25 13:14:57
问题 I use cx_Oracle module to connect to standalone Oracle server as follows import cx_Oracle CONN_INFO = { 'host': 'xxx.xx.xxx.x', 'port': 12345, 'user': 'user_name', 'psw': 'your_password', 'service': 'abc.xyz.com', } CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO) connection = cx_Oracle.connect(CONN_STR) but as scan IP doesn not have machine and its own username passoword, How do we connect? 回答1: Es described in the documentation, you can simple use the name defined in