﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
8055	Transaction error when doing loaddata	Erik Allik <eallik@…>	Ramiro Morales	"I'm using MySQL 4.1 with InnoDB tables and when doing ./manage.py loaddata data.json, I get the following traceback:


{{{
$ ./manage.py loaddata data.json 
Installing json fixture '/home/rime/www/rabakyla/packages/rime/data' from '/home/rime/www/rabakyla/packages/rime/data'.
Traceback (most recent call last):
  File ""./manage.py"", line 11, in ?
    execute_manager(settings)
  File ""/home/rime/www/rabakyla/packages/django/core/management/__init__.py"", line 301, in execute_manager
    utility.execute()
  File ""/home/rime/www/rabakyla/packages/django/core/management/__init__.py"", line 248, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/rime/www/rabakyla/packages/django/core/management/base.py"", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/home/rime/www/rabakyla/packages/django/core/management/base.py"", line 91, in execute
    output = self.handle(*args, **options)
  File ""/home/rime/www/rabakyla/packages/django/core/management/commands/loaddata.py"", line 157, in handle
    transaction.leave_transaction_management()
  File ""/home/rime/www/rabakyla/packages/django/db/transaction.py"", line 71, in leave_transaction_management
    raise TransactionManagementError(""This code isn't under transaction management"")
django.db.transaction.TransactionManagementError: This code isn't under transaction management
}}}


I initially used MyISAM tables (which are the default), then recreated the database with InnoDB tables, but it didn't help. I also discovered that the database was using latin1 instead of UTF-8 so I recreated the tables using UTF-8 as the default encoding which made the problem go away. But what disturbs me is that Django is not giving a good error message for this. I mean, latin1 and UTF8 are not even related to transactions, and even if they are due to some implementation details, it's really hard to make the guess. So I think loaddata should give a better error message!

(Running the latest revision of Django trunk)"		closed	Core (Serialization)	dev		fixed	loaddata fixtures print_exc 2.3 traceback	eallik@… tfkpayne@…	Accepted	1	0	0	0	0	0
