Django-fr

Forum

#1 26-04-2018 14:07:51

Piptonic
Membre
Inscription : 26-04-2018
Messages : 1

Migrate bugué :(

Bonjour.

Je me suis mit très récemment à Django, depuis hier enfaite, j'étais déjà conquis par la documentation du framework, alors je me suis dit que j'allais me lancer, j'ai suivis le tutoriel de la documentation.
Surprise, lors de ma première migration (qui est censé initiliser les premiers models du framework) j'ai eu plusieurs très mauvaises surprises, tout d'abord, lors du premier migrate (que j'y apporte un App comme argument ou pas), mon fichier db.sqlite3 se créer et surprise : il est mal encodé. On me propose donc de changer d'encodage, mais rien de change, je choisis donc d'en faire un fichier SQL à la place de Plain Text, aucun changement.
Je n'ai pas trouvé de "SQLite3 file" dans les associations de mon IDE (PyCharms), je ne sais pas si c'est normal ou si je dois installer à part SQLite3, malgré le fait qu'il est censé être compris dans le framework, enfin bref, mon IDE me précise que "No data source is configured to run this SQL" et me propose d'en choisir un, je trouve donc Sqlite, et le sélectionne, mais cela ne change rien..

Voici les erreurs de mon terminal :

λ python manage.py migrate intra
Traceback (most recent call last):
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\utils.py", line 83, in _execute
    return self.cursor.execute(sql)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\sqlite3\base.py", line 301, in execute
    return Database.Cursor.execute(self, query)
sqlite3.DatabaseError: database disk image is malformed

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

Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "D:\Install_Dev\Python\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "D:\Install_Dev\Python\lib\site-packages\django\core\management\__init__.py", line 365, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Install_Dev\Python\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Install_Dev\Python\lib\site-packages\django\core\management\base.py", line 335, in execute
    output = self.handle(*args, **options)
  File "D:\Install_Dev\Python\lib\site-packages\django\core\management\commands\migrate.py", line 79, in handle
    executor = MigrationExecutor(connection, self.migration_progress_callback)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\migrations\executor.py", line 18, in __init__
    self.loader = MigrationLoader(self.connection)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\migrations\loader.py", line 49, in __init__
    self.build_graph()
  File "D:\Install_Dev\Python\lib\site-packages\django\db\migrations\loader.py", line 206, in build_graph
    self.applied_migrations = recorder.applied_migrations()
  File "D:\Install_Dev\Python\lib\site-packages\django\db\migrations\recorder.py", line 61, in applied_migrations
    if self.has_table():
  File "D:\Install_Dev\Python\lib\site-packages\django\db\migrations\recorder.py", line 44, in has_table
    return self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor())
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\base\introspection.py", line 56, in table_names
    return get_names(cursor)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\base\introspection.py", line 51, in get_names
    return sorted(ti.name for ti in self.get_table_list(cursor)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\sqlite3\introspection.py", line 67, in get_table_list
    ORDER BY name""")
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\utils.py", line 100, in execute
    return super().execute(sql, params)
  File "D:\Install_Dev\Python\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:\Install_Dev\Python\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\utils.py", line 83, in _execute
    return self.cursor.execute(sql)
  File "D:\Install_Dev\Python\lib\site-packages\django\db\backends\sqlite3\base.py", line 301, in execute
    return Database.Cursor.execute(self, query)
django.db.utils.DatabaseError: database disk image is malformed

Elles s'affichent aussi si j'ai le malheur de retenter un migrate.

Contre question :
J'ai déjà tenté de réinstaller python ainsi que django.
J'ai tenter de changer d'IDE (dans le cas sou l'encodage était fautif)
J'ai même tenter de l'installer sous deux machines virtuelles différentes (une xubuntu et une archlinux) mêmes résultats.
Je tourne actuellement sous Windows 10 avec la dernière version de Python.

Je ne sais quoi d'autre ajouter mis à part : merci d'avance pour votre aide et bon code !

Dernière modification par Piptonic (26-04-2018 14:08:41)

Hors ligne

Pied de page des forums