当前位置: 首页>>代码示例>>Python>>正文


Python cx_Oracle.Error方法代码示例

本文整理汇总了Python中cx_Oracle.Error方法的典型用法代码示例。如果您正苦于以下问题:Python cx_Oracle.Error方法的具体用法?Python cx_Oracle.Error怎么用?Python cx_Oracle.Error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cx_Oracle的用法示例。


在下文中一共展示了cx_Oracle.Error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _setup_environment

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def _setup_environment(environ):
    # Cygwin requires some special voodoo to set the environment variables
    # properly so that Oracle will see them.
    if platform.system().upper().startswith('CYGWIN'):
        try:
            import ctypes
        except ImportError as e:
            from django.core.exceptions import ImproperlyConfigured
            raise ImproperlyConfigured("Error loading ctypes: %s; "
                                       "the Oracle backend requires ctypes to "
                                       "operate correctly under Cygwin." % e)
        kernel32 = ctypes.CDLL('kernel32')
        for name, value in environ:
            kernel32.SetEnvironmentVariableA(name, value)
    else:
        os.environ.update(environ) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:18,代码来源:base.py

示例2: db_connect

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def db_connect(args):
    if args.type == "mysql" or args.type == "mariadb":
        import mysql.connector
        try:
            connection = mysql.connector.connect(
                user=args.user,
                password=args.password,
                database=args.db)
        except mysql.connector.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "mssql":
        import pymssql
        try:
            connection = pymssql.connect(server="localhost", database=args.db)
        except pymssql.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "pgsql":
        import psycopg2
        try:
            connection = psycopg2.connect(
                "dbname='{}' user='{}' password='{}'".format(
                    args.db, args.user, args.password))
        except psycopg2.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None
    elif args.type == "oracle":
        import cx_Oracle
        try:
            connection = cx_Oracle.connect(
                args.user, args.password, cx_Oracle.makedsn(
                    '127.0.0.1', 1521, args.db), mode=cx_Oracle.SYSDBA)
        except cx_Oracle.Error as err:
            print(colorize("red", "[ERROR] {}".format(err)))
            return None

    return connection 
开发者ID:migolovanov,项目名称:libinjection-fuzzer,代码行数:40,代码来源:fuzzer.py

示例3: is_usable

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def is_usable(self):
        try:
            self.connection.ping()
        except Database.Error:
            return False
        else:
            return True 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:9,代码来源:base.py

示例4: _setup_environment

# 需要导入模块: import cx_Oracle [as 别名]
# 或者: from cx_Oracle import Error [as 别名]
def _setup_environment(environ):
    # Cygwin requires some special voodoo to set the environment variables
    # properly so that Oracle will see them.
    if platform.system().upper().startswith('CYGWIN'):
        try:
            import ctypes
        except ImportError as e:
            raise ImproperlyConfigured("Error loading ctypes: %s; "
                                       "the Oracle backend requires ctypes to "
                                       "operate correctly under Cygwin." % e)
        kernel32 = ctypes.CDLL('kernel32')
        for name, value in environ:
            kernel32.SetEnvironmentVariableA(name, value)
    else:
        os.environ.update(environ) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:17,代码来源:base.py


注:本文中的cx_Oracle.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。