本文整理汇总了Python中cx_Oracle.version方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.version方法的具体用法?Python cx_Oracle.version怎么用?Python cx_Oracle.version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cx_Oracle
的用法示例。
在下文中一共展示了cx_Oracle.version方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_minimum_version
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def test_minimum_version(self):
with mock.patch(
"sqlalchemy.dialects.oracle.cx_oracle.OracleDialect_cx_oracle."
"_parse_cx_oracle_ver",
lambda self, vers: (5, 1, 5),
):
assert_raises_message(
exc.InvalidRequestError,
"cx_Oracle version 5.2 and above are supported",
cx_oracle.OracleDialect_cx_oracle,
dbapi=Mock(),
)
with mock.patch(
"sqlalchemy.dialects.oracle.cx_oracle.OracleDialect_cx_oracle."
"_parse_cx_oracle_ver",
lambda self, vers: (5, 3, 1),
):
cx_oracle.OracleDialect_cx_oracle(dbapi=Mock())
示例2: test_ident_length_in_13_is_30
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def test_ident_length_in_13_is_30(self):
from sqlalchemy import __version__
m = re.match(r"(\d+)\.(\d+)(?:\.(\d+))?", __version__)
version = tuple(int(x) for x in m.group(1, 2, 3) if x is not None)
if version >= (1, 4):
length = 128
else:
length = 30
eq_(oracle.OracleDialect.max_identifier_length, length)
dialect = self._dialect((12, 2, 0))
conn = mock.Mock(
exec_driver_sql=mock.Mock(
return_value=mock.Mock(scalar=lambda: "12.2.0")
)
)
dialect.initialize(conn)
eq_(dialect.server_version_info, (12, 2, 0))
eq_(
dialect._get_effective_compat_server_version_info(conn), (12, 2, 0)
)
eq_(dialect.max_identifier_length, length)
示例3: __init__
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def __init__(self,
auto_convert_lobs=True,
threaded=True,
coerce_to_unicode=False,
coerce_to_decimal=True,
arraysize=50,
**kwargs):
self._pop_deprecated_kwargs(kwargs)
OracleDialect.__init__(self, **kwargs)
self.threaded = threaded
self.arraysize = arraysize
self.auto_convert_lobs = auto_convert_lobs
self.coerce_to_unicode = coerce_to_unicode
self.coerce_to_decimal = coerce_to_decimal
cx_Oracle = self.dbapi
if cx_Oracle is None:
self._include_setinputsizes = {}
self.cx_oracle_ver = (0, 0, 0)
else:
self.cx_oracle_ver = self._parse_cx_oracle_ver(cx_Oracle.version)
if self.cx_oracle_ver < (5, 0) and self.cx_oracle_ver > (0, 0, 0):
raise exc.InvalidRequestError(
"cx_Oracle version 5.0 and above are supported")
self._has_native_int = hasattr(cx_Oracle, "NATIVE_INT")
self._include_setinputsizes = {
cx_Oracle.NCLOB, cx_Oracle.CLOB, cx_Oracle.LOB,
cx_Oracle.BLOB, cx_Oracle.FIXED_CHAR,
}
self._is_cx_oracle_6 = self.cx_oracle_ver >= (6, )
示例4: _parse_cx_oracle_ver
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _parse_cx_oracle_ver(self, version):
m = re.match(r'(\d+)\.(\d+)(?:\.(\d+))?', version)
if m:
return tuple(
int(x)
for x in m.group(1, 2, 3)
if x is not None)
else:
return (0, 0, 0)
示例5: _get_server_version_info
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _get_server_version_info(self, connection):
return tuple(
int(x)
for x in connection.connection.version.split('.')
)
示例6: _cursor_var_unicode_kwargs
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _cursor_var_unicode_kwargs(self):
if self.encoding_errors:
if self.cx_oracle_ver >= (6, 4):
return {"encodingErrors": self.encoding_errors}
else:
util.warn(
"cx_oracle version %r does not support encodingErrors"
% (self.cx_oracle_ver,)
)
return {}
示例7: _parse_cx_oracle_ver
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _parse_cx_oracle_ver(self, version):
m = re.match(r"(\d+)\.(\d+)(?:\.(\d+))?", version)
if m:
return tuple(int(x) for x in m.group(1, 2, 3) if x is not None)
else:
return (0, 0, 0)
示例8: _get_server_version_info
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _get_server_version_info(self, connection):
return tuple(int(x) for x in connection.connection.version.split("."))
示例9: cx_Oracle
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def cx_Oracle(self):
return mock.Mock(
NUMBER=self.cx_Oracle_NUMBER,
STRING=self.cx_Oracle_STRING,
FIXED_CHAR=self.cx_Oracle_FIXED_CHAR,
CLOB=self.cx_Oracle_CLOB,
NCLOB=self.cx_Oracle_NCLOB,
version="7.0.1",
__future__=mock.Mock(),
)
示例10: _dialect
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def _dialect(self, server_version, **kw):
def server_version_info(conn):
return server_version
dialect = oracle.dialect(
dbapi=Mock(version="0.0.0", paramstyle="named"), **kw
)
dialect._get_server_version_info = server_version_info
dialect._check_unicode_returns = Mock()
dialect._check_unicode_description = Mock()
dialect._get_default_schema_name = Mock()
dialect._detect_decimal_char = Mock()
dialect.__check_max_identifier_length = Mock()
dialect._get_compat_server_version_info = Mock()
return dialect
示例11: test_default_flags
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def test_default_flags(self):
"""test with no initialization or server version info"""
dialect = self._dialect(None)
assert dialect._supports_char_length
assert not dialect._use_nchar_for_unicode
assert dialect.use_ansi
self.assert_compile(String(50), "VARCHAR2(50 CHAR)", dialect=dialect)
self.assert_compile(Unicode(50), "VARCHAR2(50 CHAR)", dialect=dialect)
self.assert_compile(UnicodeText(), "CLOB", dialect=dialect)
示例12: __init__
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def __init__(self,
auto_convert_lobs=True,
threaded=True,
coerce_to_unicode=False,
coerce_to_decimal=True,
arraysize=50,
**kwargs):
self._pop_deprecated_kwargs(kwargs)
OracleDialect.__init__(self, **kwargs)
self.threaded = threaded
self.arraysize = arraysize
self.auto_convert_lobs = auto_convert_lobs
self.coerce_to_unicode = coerce_to_unicode
self.coerce_to_decimal = coerce_to_decimal
cx_Oracle = self.dbapi
if cx_Oracle is None:
self._include_setinputsizes = {}
self.cx_oracle_ver = (0, 0, 0)
else:
self.cx_oracle_ver = self._parse_cx_oracle_ver(cx_Oracle.version)
if self.cx_oracle_ver < (5, 2) and self.cx_oracle_ver > (0, 0, 0):
raise exc.InvalidRequestError(
"cx_Oracle version 5.2 and above are supported")
self._has_native_int = hasattr(cx_Oracle, "NATIVE_INT")
self._include_setinputsizes = {
cx_Oracle.NCLOB, cx_Oracle.CLOB, cx_Oracle.LOB,
cx_Oracle.NCHAR, cx_Oracle.FIXED_NCHAR,
cx_Oracle.BLOB, cx_Oracle.FIXED_CHAR, cx_Oracle.TIMESTAMP,
_OracleInteger, _OracleBINARY_FLOAT, _OracleBINARY_DOUBLE
}
self._paramval = lambda value: value.getvalue()
# https://github.com/oracle/python-cx_Oracle/issues/176#issuecomment-386821291
# https://github.com/oracle/python-cx_Oracle/issues/224
self._values_are_lists = self.cx_oracle_ver >= (6, 3)
if self._values_are_lists:
cx_Oracle.__future__.dml_ret_array_val = True
def _returningval(value):
try:
return value.values[0][0]
except IndexError:
return None
self._returningval = _returningval
else:
self._returningval = self._paramval
self._is_cx_oracle_6 = self.cx_oracle_ver >= (6, )
示例13: create_connection
# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import version [as 别名]
def create_connection(self):
service_check_tags = ['server:%s' % self._server]
service_check_tags.extend(self._tags)
try:
# Check if the instantclient is available
cx_Oracle.clientversion()
except cx_Oracle.DatabaseError as e:
# Fallback to JDBC
use_oracle_client = False
self.log.debug('Oracle instant client unavailable, falling back to JDBC: %s', e)
connect_string = self.JDBC_CONNECT_STRING.format(self._server, self._service)
else:
use_oracle_client = True
self.log.debug('Running cx_Oracle version %s', cx_Oracle.version)
connect_string = self.CX_CONNECT_STRING.format(self._user, self._password, self._server, self._service)
try:
if use_oracle_client:
connection = cx_Oracle.connect(connect_string)
elif JDBC_IMPORT_ERROR:
self.log.error(
"Oracle client is unavailable and the integration is unable to import JDBC libraries. You may not "
"have the Microsoft Visual C++ Runtime 2015 installed on your system. Please double check your "
"installation and refer to the Datadog documentation for more information."
)
raise JDBC_IMPORT_ERROR
else:
try:
if jpype.isJVMStarted() and not jpype.isThreadAttachedToJVM():
jpype.attachThreadToJVM()
jpype.java.lang.Thread.currentThread().setContextClassLoader(
jpype.java.lang.ClassLoader.getSystemClassLoader()
)
connection = jdb.connect(
self.ORACLE_DRIVER_CLASS, connect_string, [self._user, self._password], self._jdbc_driver
)
except Exception as e:
if "Class {} not found".format(self.ORACLE_DRIVER_CLASS) in str(e):
msg = """Cannot run the Oracle check until either the Oracle instant client or the JDBC Driver
is available.
For the Oracle instant client, see:
http://www.oracle.com/technetwork/database/features/instant-client/index.html
You will also need to ensure the `LD_LIBRARY_PATH` is also updated so the libs are reachable.
For the JDBC Driver, see:
http://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html
You will also need to ensure the jar is either listed in your $CLASSPATH or in the yaml
configuration file of the check.
"""
self.log.error(msg)
raise
self.log.debug("Connected to Oracle DB")
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.OK, tags=service_check_tags)
except Exception as e:
self.service_check(self.SERVICE_CHECK_NAME, AgentCheck.CRITICAL, tags=service_check_tags)
self.log.error(e)
raise
self._connection = connection