我需要一个R脚本,它允许我连接到Oracle数据库,而无需安装任何需要管理员权限的东西,最好除了软件包下载之外什么都不安装。在python中,以下代码是有效的,我相信这是因为它使用cx_Oracle模块作为可移植驱动程序。什么是好的R替代品?
import pandas as pd
import sqlalchemy
import sys
host = "xxx.intra"
database = "mydb"
user = "usr"
password = "pw"
def get_oracle_engine(host, database, user, password):
return sqlalchemy.create_engine("oracle+cx_oracle://{user}:{password}@{host}:1521/?service_name={database}".format(host=host, database=database, user=user, password=password))
engine=get_oracle_engine(host, database, user, password)
pd.read_sql_table("mytable", engine, schema= mydb,index.cols="id1")
我设法使用安装了ROracle
the CRAN instructions
但我一直得到
ORA-12154 TNS: cound not resolve the connect identifier specified
使用时:
library(ROracle)
con= DBI::dbconnect(dbDriver("Oracle"), user= user, password=password, host=host, dbname=database, port="1521")
顺便说一句
dbDriver("Oracle")
退货
Driver name : Oracle (OCI)
Driver version: 1.3-1
Client version: 12.1.0.2.0