0

I have a project where i need to use django with Nexus DB.

I have customized django-pyodbc package to nexusDB compactable as third party Database engine. But While making the initial migration found this error.

Traceback (most recent call last):
File "D:\Projects\xxx\venv\lib\site- 
packages\django\db\migrations\recorder.py", line 55, in ensure_schema
editor.create_model(self.Migration)
File "D:\Projects\xxx\venv\lib\site- 
packages\django\db\backends\base\schema.py", line 312, in create_model
self.execute(sql, params or None)
File "D:\Projects\xxx\venv\lib\site- 
packages\django\db\backends\base\schema.py", line 133, in execute
cursor.execute(sql, params)
File "D:\Projects\xxx\venv\lib\site- 
packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "D:\Projects\xxx\venv\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 "D:\Projects\xxx\venv\lib\site- 
packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "D:\Projects\xxx\venv\lib\site- 
packages\django\db\backends\utils.py", line 83, in _execute
return self.cursor.execute(sql)
File "D:\Projects\xxx\django_pyodbc\base.py", line 485, in execute
raise utils.DatabaseError(*e.args)
django.db.utils.DatabaseError: ('HY000', '[HY000] The query returned an 
error (ODBC State: HY000)\r\rError:\rNexusDB: <unnamed TnxODBCQuery 
instance>: Query execution failed: \r\nTable already exists. (Tablename: 
django_migrations)\r\n\r\n [$3304/13060]\r\rQuery:\rCREATE TABLE  
django_migrations  ( id  AUTOINC NOT NULL PRIMARY KEY,  app  NULLSTRING  
NOT NULL,  name  NULLSTRING  NOT NULL,  applied  DATETIME NOT NULL)\r\r 
(-1) (SQLExecDirectW)')

Can anyone help me on this ?

Thanks

Arun Augustine
  • 1,690
  • 1
  • 13
  • 20
  • Which `django-pyodbc` did you fork from? Do you have a link to the repository? It looks like you've already run a migration to create the `django_migrations` table. You may be able to fake it using the `--fake-initial` options, or inserting the row manually into `django_migrations` that is causing the migration to run again. – FlipperPA Jun 07 '19 at 10:13
  • I have forked `django-pyodbc==2.0.0a1`. and i tried `--fake-initial` but fails with the same error. – Arun Augustine Jun 07 '19 at 10:26
  • Sorry I wasn't more clear, what is the URL to the `django-pyodbc` you tried to fork from? There are several different versions, some of which are no longer maintained. – FlipperPA Jun 07 '19 at 19:54
  • I just installed `pip install django-pyodbc==2.0.0a1`. which is django 2.0 compact-able alpha version. – Arun Augustine Jun 10 '19 at 01:36
  • @FlipperPA, I have tried with `https://pypi.org/project/django-pyodbc-azure/` package(made changes for Nexus DB). It is compact-able with django21 but again the same error is occurring. Initially the django migrations table is created in the Database and then while migrating basic content types again the same create table query is executing from the django site package. – Arun Augustine Jun 11 '19 at 02:09

0 Answers0