0

I am working on a college project for which I am supposed to use oracle database as the backend and I have chosen to work with django as the programming language. I have successfully connected django with oracle 12c and also have cx_Oracle installed. But when i try to run the command

py manage.py migrate

the following errors show up.

Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Users\Hp\Desktop\onlinepharma> py manage.py migrate
Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, testing Running migrations: Applying contenttypes.0001_initial...Traceback (most recent call last): File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-
packages\django\db\backends\utils.py", line 83, in _execute return self.cursor.execute(sql) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\oracle\base.py", line 513, in execute return self.cursor.execute(query, self._param_generator(params)) cx_Oracle.DatabaseError: ORA-00955: name is already used by an existing object

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "manage.py", line 15, in execute_from_command_line(sys.argv) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management__init__.py", line 381, in execute_from_command_line utility.execute() File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv self.execute(*args, **cmd_options) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 353, in execute output = self.handle(*args, **options) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 83, in wrapped res = handle_func(*args, **kwargs) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\migrate.py", line 203, in handle fake_initial=fake_initial, File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\executor.py", line 117, in migrate state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\executor.py", line 147, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\executor.py", line 244, in apply_migration state = migration.apply(state, schema_editor) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\migration.py", line 124, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\migrations\operations\models.py", line 91, in database_forwards schema_editor.create_model(model) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\base\schema.py", line 312, in create_model self.execute(sql, params or None) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\base\schema.py", line 133, in execute cursor.execute(sql, params) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 100, in execute return super().execute(sql, params) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 85, in _execute return self.cursor.execute(sql, params) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\utils.py", line 89, in exit raise dj_exc_value.with_traceback(traceback) from exc_value File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\utils.py", line 83, in _execute return self.cursor.execute(sql) File "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\oracle\base.py", line 513, in execute return self.cursor.execute(query, self._param_generator(params)) django.db.utils.DatabaseError: ORA-00955: name is already used by an existing object

Here's my model.py file

from django.db import models

# Create your models here.
class yoman(models.Model):
text=models.CharField(max_length=200)

But I have checked using sql command line and no such db table or view exists.

p.s: The makemigrations command works properly and the migratiosn file has also been created.

1 Answer 1

1

You can print out the sql query if you edit the following file: "C:\Users\Hp\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\backends\oracle\base.py On line 513, before the execute function is called add:

print(f'query')

Rerun the migration and you can see the sql that is failing to run. Either remove or rename the table/object in the db.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.