mysql - migrate in django to legacy database gives error -


background info: quite beginner django, better equipped python , quite beginner in mysql (and mariadb) well. work in windows 7 environment following versions:

  • django 1.9.1
  • mariadb 10.0.20
  • python 3.4.4
  • mysql-connector\python 2.1.3 python 3.4

goal: trying build mariadb database , web based user interface django. have built database beforehand in mysql , trying create django project using database legacy database.

problem: have retrieved models django project follows:

python manage.py inspectdb > models.py 

and worked fine. checked models.py, well, , seemed should.

now, if try migrate create tables based on django legacy db follows:

python manage.py migrate 

i keep getting plenty of nested errors last 1 being:

django.db.migrations.exceptions.migrationsschemamissing: unable create django_migrations table (table 'mydb'.'django_migrations' exists. please discard tablespace before import.) 

i figured table left in database folder previous attempt, removing not help. if check database command prompt tables left native database, same error message pops still. @ point wondered if there issue connector using not recommended 1 (mysqlclient).

somewhere, found migration not required. save me, have no idea, if solution can go for. ideally database managed later online , users admin accounts add entries there. otherwise, database should returning data.

edit: fixed error message python manage.py inspectdb > models.py line

edit 29.1. running migration as:

python manage.py migrate --fake 

results in same error.

the issue persists after removing django project , starting fresh.

edit v2 29.1. there 1 of required table files django_migrations table within database folder. there should django_migrations.ibd , django_migrations.frm. however, after running migration, there 1 file: django_migrations.ibd.

there similar going on here, different file mysqldump problems restore error: 'please discard tablespace before import'. explained in chosen answer.

i think related issue, cannot figure out , this.

edit v3 29.1. , noticed file giving django error. django's migration recorder @ c:\python34\lib\site-packages\django\db\migrations\recorder.py on line 59.

def ensure_schema(self):     """     ensures table exists , has correct schema.     """     # if table's there, that's fine - we've never changed schema     # in codebase.     if self.migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):         return     # make table     try:         self.connection.schema_editor() editor:             editor.create_model(self.migration)     except databaseerror exc:         raise migrationschemamissing("unable create django_migrations table (%s)" % exc) 

where last line raising error line 59. funnily, function should work, if table exists. thing can come (as in previous edit), indeed reason frm-file not created during migration process.

why happens way beyond me.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -