當前位置: 首頁>>代碼示例>>Python>>正文


Python errorcodes.DUPLICATE_DATABASE屬性代碼示例

本文整理匯總了Python中psycopg2.errorcodes.DUPLICATE_DATABASE屬性的典型用法代碼示例。如果您正苦於以下問題:Python errorcodes.DUPLICATE_DATABASE屬性的具體用法?Python errorcodes.DUPLICATE_DATABASE怎麽用?Python errorcodes.DUPLICATE_DATABASE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在psycopg2.errorcodes的用法示例。


在下文中一共展示了errorcodes.DUPLICATE_DATABASE屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _execute_create_test_db

# 需要導入模塊: from psycopg2 import errorcodes [as 別名]
# 或者: from psycopg2.errorcodes import DUPLICATE_DATABASE [as 別名]
def _execute_create_test_db(self, cursor, parameters, keepdb=False):
        try:
            if keepdb and self._database_exists(cursor, parameters['dbname']):
                # If the database should be kept and it already exists, don't
                # try to create a new one.
                return
            super()._execute_create_test_db(cursor, parameters, keepdb)
        except Exception as e:
            if getattr(e.__cause__, 'pgcode', '') != errorcodes.DUPLICATE_DATABASE:
                # All errors except "database already exists" cancel tests.
                sys.stderr.write('Got an error creating the test database: %s\n' % e)
                sys.exit(2)
            elif not keepdb:
                # If the database should be kept, ignore "database already
                # exists".
                raise e 
開發者ID:PacktPublishing,項目名稱:Hands-On-Application-Development-with-PyCharm,代碼行數:18,代碼來源:creation.py

示例2: _execute_create_test_db

# 需要導入模塊: from psycopg2 import errorcodes [as 別名]
# 或者: from psycopg2.errorcodes import DUPLICATE_DATABASE [as 別名]
def _execute_create_test_db(self, cursor, parameters, keepdb=False):
        try:
            super()._execute_create_test_db(cursor, parameters, keepdb)
        except Exception as e:
            if getattr(e.__cause__, 'pgcode', '') != errorcodes.DUPLICATE_DATABASE:
                # All errors except "database already exists" cancel tests.
                sys.stderr.write('Got an error creating the test database: %s\n' % e)
                sys.exit(2)
            elif not keepdb:
                # If the database should be kept, ignore "database already
                # exists".
                raise e 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:14,代碼來源:creation.py

示例3: _execute_raise_database_already_exists

# 需要導入模塊: from psycopg2 import errorcodes [as 別名]
# 或者: from psycopg2.errorcodes import DUPLICATE_DATABASE [as 別名]
def _execute_raise_database_already_exists(self, cursor, parameters, keepdb=False):
        error = DatabaseError('database %s already exists' % parameters['dbname'])
        error.pgcode = errorcodes.DUPLICATE_DATABASE
        raise DatabaseError() from error 
開發者ID:nesdis,項目名稱:djongo,代碼行數:6,代碼來源:test_creation.py


注:本文中的psycopg2.errorcodes.DUPLICATE_DATABASE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。