Tuesday, November 4, 2014

running unit tests with legacy database: Error 1050, Table already exists

Hello,
I'm relatively new to Django, so it might well be a silly question...
I'm using Django-1.7 with Python-3.3.
I'm working with a legacy MySQL database. I tried both pymysql and mysql-connector-python, the errors are similar.

When I run the unit tests, for instance, with mysql-connector-python, I get
python manage.py test jobwatcher
...
mysql
.connector.errors.ProgrammingError: 1050 (42S01): Table 'auth_group' already exists

During handling of the above exception, another exception occurred:
...
 
File "/test/virtualenv/lib/python3.3/site-packages/mysql/connector/connection.py", line 638, in _handle_result
   
raise errors.get_exception(packet)
django
.db.utils.ProgrammingError: Table 'auth_group' already exists

I read that one has to use the inspectdb command to generate the models when working with legacy databases, so I did; and I also set the "managed" variale to False in the meta thing. For instance:
class JobMon(models.Model):
    id
= models.BigIntegerField(primary_key=True)
    job_db_inx
= models.IntegerField()
    value_avg
= models.BigIntegerField()
    value_sum
= models.BigIntegerField()
    mon_type
= models.IntegerField()
    timestamp
= models.IntegerField()
    is_valid
= models.IntegerField()
    is_full
= models.IntegerField()
    nodes_nr
= models.IntegerField()

   
class Meta:
        managed
= False
        db_table
= 'job_mon'


I tried different things, but I'm just shooting in the dark right now.

Can anyone give me a hint of whats going on and/or how to solve this problem?

TIA,

David

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4fdad4c1-b28e-4b4e-91ff-b892ea9289c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment