New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate entry when loading data to MySQL #30

Closed
konrad1234 opened this Issue Oct 30, 2013 · 8 comments

Comments

Projects
None yet
3 participants
@konrad1234

konrad1234 commented Oct 30, 2013

Hey,

This is my first post on Github so let me know if I'm not explaining myself properly.

The command "python manage.py cities_light" kept giving me this error:

No handlers could be found for logger "cities_light"

So then I tried this command: python manage.py cities_light --force-import-all

Now I get this error:

IntegrityError: (1062, "Duplicate entry '1900-Daugavpils' for key 'cities_light_region_country_id_1935599b8f52157f_uniq'")

The "1900" in '1900-Daugavpils' keeps changing to a different number each time I've tried it. This small Latvian town is giving me a huge headache. Any solutions?

Thanks!

@jpic

This comment has been minimized.

Show comment
Hide comment
@jpic

jpic Oct 30, 2013

Member

Could you try setting the cities_light logger like in the test project ? https://github.com/yourlabs/django-cities-light/blob/master/test_project/test_project/settings.py

Yes, you need --force-import-all after an interrupted manage.py cities_light.

Member

jpic commented Oct 30, 2013

Could you try setting the cities_light logger like in the test project ? https://github.com/yourlabs/django-cities-light/blob/master/test_project/test_project/settings.py

Yes, you need --force-import-all after an interrupted manage.py cities_light.

@konrad1234

This comment has been minimized.

Show comment
Hide comment
@konrad1234

konrad1234 Oct 30, 2013

Set it to what's below and tried the force-import-all again and the same issue occurs:

'loggers': {
    'django.request': {
        'handlers': ['mail_admins'],
        'level': 'ERROR',
        'propagate': True,
    },
    'cities_light': {
        'handlers':['console'],
        'propagate': True,
        'level':'DEBUG',
    },
}

Here's the response in full:

python manage.py cities_light --force-import-all
No handlers could be found for logger "cities_light"
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/autoslug/utils.py:30: RuntimeWarning: Argument <type 'str'> is not an unicode object. Passing an encoded string will likely have unexpected results.
return django_slugify(unidecode(value))

RAM used: 28274688 kB Time: 0:00:00 Done: 100%|##############################################################################################################|
IntegrityError: (1062, "Duplicate entry '2908-Daugavpils' for key 'cities_light_region_country_id_1935599b8f52157f_uniq'")

konrad1234 commented Oct 30, 2013

Set it to what's below and tried the force-import-all again and the same issue occurs:

'loggers': {
    'django.request': {
        'handlers': ['mail_admins'],
        'level': 'ERROR',
        'propagate': True,
    },
    'cities_light': {
        'handlers':['console'],
        'propagate': True,
        'level':'DEBUG',
    },
}

Here's the response in full:

python manage.py cities_light --force-import-all
No handlers could be found for logger "cities_light"
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/autoslug/utils.py:30: RuntimeWarning: Argument <type 'str'> is not an unicode object. Passing an encoded string will likely have unexpected results.
return django_slugify(unidecode(value))

RAM used: 28274688 kB Time: 0:00:00 Done: 100%|##############################################################################################################|
IntegrityError: (1062, "Duplicate entry '2908-Daugavpils' for key 'cities_light_region_country_id_1935599b8f52157f_uniq'")

@konrad1234 konrad1234 closed this Oct 30, 2013

@konrad1234 konrad1234 reopened this Oct 30, 2013

@jpic

This comment has been minimized.

Show comment
Hide comment
@jpic

jpic Oct 31, 2013

Member

That's a real problem, could you please paste your CITIES_LIGHT_* settings ?

BTW, I think that "No loggers found for cities_light" is a non-blocking warning, instead of an actual error. Could you confirm that ?

Thanks

Member

jpic commented Oct 31, 2013

That's a real problem, could you please paste your CITIES_LIGHT_* settings ?

BTW, I think that "No loggers found for cities_light" is a non-blocking warning, instead of an actual error. Could you confirm that ?

Thanks

@Tyrdall

This comment has been minimized.

Show comment
Hide comment
@Tyrdall

Tyrdall Oct 31, 2013

Got the same issue. Made no use of any settings.

If I rebuild the database and then proceed with ./manage.py cities_light nothing happens at all. If I use --force-import-all I get the duplicate error.

IntegrityError: duplicate key value violates unique constraint "cities_light_region_country_id_70adea81_uniq" DETAIL:  Key (country_id, name)=(136, Daugavpils) already exists.

If I redo the command the number (136) is increasing.

Tyrdall commented Oct 31, 2013

Got the same issue. Made no use of any settings.

If I rebuild the database and then proceed with ./manage.py cities_light nothing happens at all. If I use --force-import-all I get the duplicate error.

IntegrityError: duplicate key value violates unique constraint "cities_light_region_country_id_70adea81_uniq" DETAIL:  Key (country_id, name)=(136, Daugavpils) already exists.

If I redo the command the number (136) is increasing.

@konrad1234

This comment has been minimized.

Show comment
Hide comment
@konrad1234

konrad1234 Oct 31, 2013

jpic, what part of my settings do you need me to paste?

konrad1234 commented Oct 31, 2013

jpic, what part of my settings do you need me to paste?

@jpic

This comment has been minimized.

Show comment
Hide comment
@jpic

jpic Nov 2, 2013

Member

Thanks for your feedback, I think the cities_light command should just skip duplicates, do you think that would work well ?

Member

jpic commented Nov 2, 2013

Thanks for your feedback, I think the cities_light command should just skip duplicates, do you think that would work well ?

@konrad1234

This comment has been minimized.

Show comment
Hide comment
@konrad1234

konrad1234 Nov 2, 2013

Ya, sure. Thanks!

konrad1234 commented Nov 2, 2013

Ya, sure. Thanks!

@jpic

This comment has been minimized.

Show comment
Hide comment
@jpic

jpic Nov 2, 2013

Member

IntegrityError are caught in 2.1.2. Please re-open if the issue persists.

Member

jpic commented Nov 2, 2013

IntegrityError are caught in 2.1.2. Please re-open if the issue persists.

@jpic jpic closed this Nov 2, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment