示例#1
0
 def _execute_raise_permission_denied(self,
                                      cursor,
                                      parameters,
                                      keepdb=False):
     error = DatabaseError('permission denied to create database')
     error.pgcode = errorcodes.INSUFFICIENT_PRIVILEGE
     raise DatabaseError() from error
示例#2
0
 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
示例#3
0
 def _execute_raise_insufficient_privileges(self,
                                            cursor,
                                            statements,
                                            parameters,
                                            verbosity,
                                            allow_quiet_fail=False):
     raise DatabaseError("ORA-01031: insufficient privileges")
示例#4
0
 def _execute_raise_tablespace_already_exists(self,
                                              cursor,
                                              statements,
                                              parameters,
                                              verbosity,
                                              allow_quiet_fail=False):
     raise DatabaseError("ORA-01543: tablespace 'string' already exists")
示例#5
0
 def fetch_returned_insert_id(self, cursor):
     try:
         return int(cursor._insert_id_var.getvalue())
     except (IndexError, TypeError):
         # cx_Oracle < 6.3 returns None, >= 6.3 raises IndexError.
         raise DatabaseError(
             'The database did not return a new row id. Probably "ORA-1403: '
             'no data found" was raised internally but was hidden by the '
             'Oracle OCI library (see https://code.djangoproject.com/ticket/28859).'
         )
示例#6
0
 def _execute_raise_user_already_exists(self,
                                        cursor,
                                        statements,
                                        parameters,
                                        verbosity,
                                        allow_quiet_fail=False):
     # Raise "user already exists" only in test user creation
     if statements and statements[0].startswith('CREATE USER'):
         raise DatabaseError(
             "ORA-01920: user name 'string' conflicts with another user or role name"
         )
示例#7
0
文件: base.py 项目: iMerica/dj-models
 def validate_thread_sharing(self):
     """
     Validate that the connection isn't accessed by another thread than the
     one which originally created it, unless the connection was explicitly
     authorized to be shared between threads (via the `allow_thread_sharing`
     property). Raise an exception if the validation fails.
     """
     if not (self.allow_thread_sharing
             or self._thread_ident == _thread.get_ident()):
         raise DatabaseError(
             "DatabaseWrapper objects created in a "
             "thread can only be used in that same thread. The object "
             "with alias '%s' was created in thread id %s and this is "
             "thread id %s." %
             (self.alias, self._thread_ident, _thread.get_ident()))
示例#8
0
 def _execute_raise_access_denied(self, cursor, parameters, keepdb=False):
     raise DatabaseError(1044, "Access denied for user")
示例#9
0
 def _execute_raise_database_exists(self, cursor, parameters, keepdb=False):
     raise DatabaseError(
         1007, "Can't create database '%s'; database exists" %
         parameters['dbname'])