Python cx_Oracle.version() Examples
The following are 18
code examples of cx_Oracle.version().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cx_Oracle
, or try the search function
.
Example #1
Source File: test_dialect.py From sqlalchemy with MIT License | 6 votes |
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())
Example #2
Source File: test_dialect.py From sqlalchemy with MIT License | 6 votes |
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)
Example #3
Source File: cx_oracle.py From planespotter with MIT License | 5 votes |
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)
Example #4
Source File: cx_oracle.py From android_universal with MIT License | 5 votes |
def _get_server_version_info(self, connection): return tuple( int(x) for x in connection.connection.version.split('.') )
Example #5
Source File: cx_oracle.py From android_universal with MIT License | 5 votes |
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)
Example #6
Source File: cx_oracle.py From jarvis with GNU General Public License v2.0 | 5 votes |
def _get_server_version_info(self, connection): return tuple( int(x) for x in connection.connection.version.split('.') )
Example #7
Source File: cx_oracle.py From jarvis with GNU General Public License v2.0 | 5 votes |
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)
Example #8
Source File: cx_oracle.py From jarvis with GNU General Public License v2.0 | 5 votes |
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, )
Example #9
Source File: test_dialect.py From sqlalchemy with MIT License | 5 votes |
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)
Example #10
Source File: test_dialect.py From sqlalchemy with MIT License | 5 votes |
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
Example #11
Source File: test_dialect.py From sqlalchemy with MIT License | 5 votes |
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(), )
Example #12
Source File: cx_oracle.py From sqlalchemy with MIT License | 5 votes |
def _get_server_version_info(self, connection): return tuple(int(x) for x in connection.connection.version.split("."))
Example #13
Source File: cx_oracle.py From sqlalchemy with MIT License | 5 votes |
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)
Example #14
Source File: cx_oracle.py From sqlalchemy with MIT License | 5 votes |
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 {}
Example #15
Source File: cx_oracle.py From planespotter with MIT License | 5 votes |
def _get_server_version_info(self, connection): return tuple( int(x) for x in connection.connection.version.split('.') )
Example #16
Source File: cx_oracle.py From planespotter with MIT License | 5 votes |
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, )
Example #17
Source File: cx_oracle.py From android_universal with MIT License | 4 votes |
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, )
Example #18
Source File: oracle.py From integrations-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
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