子流程是否是cx_oracle for python的唯一替代方案—连接到oracledb
我在python中使用cx_Oracle已有一段时间了,sqlalchemy也在内部使用它连接到Oracle。但最近,我遇到了一些无法安装cx_Oracle的solaris设备,因此我想知道在子流程中使用sqlplus似乎是运行查询的唯一其他方法 还有其他选择吗子流程是否是cx_oracle for python的唯一替代方案—连接到oracledb,python,subprocess,cx-oracle,Python,Subprocess,Cx Oracle,我在python中使用cx_Oracle已有一段时间了,sqlalchemy也在内部使用它连接到Oracle。但最近,我遇到了一些无法安装cx_Oracle的solaris设备,因此我想知道在子流程中使用sqlplus似乎是运行查询的唯一其他方法 还有其他选择吗 import cx_Oracle import logging class Oracle(object): """ Connector class to connect to Oracle database and run
import cx_Oracle
import logging
class Oracle(object):
"""
Connector class to connect to Oracle database and run queries
"""
def __init__(self, db_config):
# mode should be 0 if not cx_Oracle.SYSDBA
self.logger = logging.getLogger(__name__)
if db_config:
self.username = db_config["username"]
self.password = db_config["password"]
self.host = db_config["host"]
self.port = db_config["port"]
self.sid = db_config["sid"]
self.mode = int(db_config["mode"])
self._cursor = None
self._connection = None
self.connect_string = self.username + '/' + self.password + '@' + self.host + ':' + self.port + '/' + self.sid
try:
self._connection = cx_Oracle.connect(self.connect_string, mode=self.mode, threaded=True)
self._cursor = self._connection.cursor()
self.idVar = self._cursor.var(cx_Oracle.NUMBER)
except Exception as e:
print "Exception while trying to initialize database connection object : ", e
else:
raise DbConfigNotFoundException
def param_query(self, q, param):
try:
self._cursor.execute(q, param)
return self._cursor.fetchall()
except Exception as e:
logger.exception(e)
raise
cx_Oracle在Solaris上应该可以正常运行。你遇到问题了吗?如果是这样,您能告诉我们有什么问题吗?配置cx\U Oracle很麻烦:cx\U Oracle:ImportError:DLL加载失败:此应用程序失败