當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。