1 (edited by xenotales 2013-04-26 13:00:29)

Topic: Mismatch between the MusicBrainz website and local database

I am connecting to the MusicBrainz database using the psycopg2 python's module for a school project. I have followed the instructions presented on http://musicbrainz.org/doc/MusicBrainz_Server/Setup, but I have strainge results when I try to query the database.

For example if I  execute the following query trying to look for the musicbrainz id of John Lennon:

    cur.execute("select * from artist inner join artist_name on artist_name.id=artist.id where artist_name.name='John Lennon';")
    print cur.fetchone()

I get the following result:

    (630713, '97d898cb-5c5a-4c3d-84df-b9d4182f2535', 73866, 418158, None, None, None, None, None, None, 1, 170, 1, '', 0, datetime.datetime(2011, 12, 4, 21, 55, 0, 491528, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), False, 630713, 'John Lennon')

So, in this case the musicbrainz id of the artist is 97d898cb-5c5a-4c3d-84df-b9d4182f2535. If I try to look for that id I discover that it points to Grzegorz Piotrowski and not John Lennon.
Also, if I try to look for the name of the artist that corresponds to the actual John Lennon id ('4d5447d7-c61c-4120-ba1b-d7f471d385b9'):

    mbid = '4d5447d7-c61c-4120-ba1b-d7f471d385b9'
    cur.execute("select * from artist inner join artist_name on artist_name.id=artist.id where artist.gid='4d5447d7-c61c-4120-ba1b-d7f471d385b9';")
print cur.fetchone()

I get the following result:

    (815, '4d5447d7-c61c-4120-ba1b-d7f471d385b9', 630713, 642211, 1940, 10, 9, 1980, 12, 8, 1, 221, 1, '', 0, datetime.datetime(2012, 7, 11, 7, 38, 12, 340777, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)), True, 815, 'Johanz Westerman')

In this case it says that this id corresponds to Johanz Westerman. Why I have this mismatch?

Re: Mismatch between the MusicBrainz website and local database

Actually I have solved the issue by myself. The problem is that I misunderstood the primary keys of artist and artist_name.

Re: Mismatch between the MusicBrainz website and local database

This is a followup-discussion on:
http://stackoverflow.com/questions/1622 … 2_16233906

I really wouldn't recommend working on the MB-DB directly.
While possible, it is quite complex and it also changes.

Please do invest some time to get to know musicbrainzngs and the web service.
You keep trying to tell me things that musicbrainzngs (using the web service) doesn't support, while it does.
There is an updated documentation that will be merged to master soon. Maybe this makes it easier to understand what the library can do:
https://python-musicbrainz-ngs-jonnyjd. … tist_by_id

To get relationships you would do something like:

    
    artist = "c5c2ea1c-4bde-4f4d-bd0b-47b200bf99d6"
    result = musicbrainzngs.get_artist_by_id(artist, includes=["artist-rels"])
    rel_list = result["artist"]["artist-relation-list"]
    for rel in rel_list:
        print(rel)

This works similar for other entities.

If you do find something that musicbrainzngs really doesn't support, than tell us. It might just be something we forgot.

Also have a look at http://musicbrainz.org/doc/Development/ … ationships

Re: Mismatch between the MusicBrainz website and local database

Thank you very much for your help! Actually I did not understood this functionalities from the "master" documentation", but I'm glad that you clarified this for me. Now I am sure that I can work with the web service and leave the database aside.