diff --git a/ippisite/db.sqlite3.REMOVED.git-id b/ippisite/db.sqlite3.REMOVED.git-id index 082a3b3a3887cd900104c3af13890ea4e1ab9251..dc41e52df23e0086cc2a543909651dbd0fd66784 100644 --- a/ippisite/db.sqlite3.REMOVED.git-id +++ b/ippisite/db.sqlite3.REMOVED.git-id @@ -1 +1 @@ -22fcf51cee85dcecd7c0de2fecdd0852abb2ce71 \ No newline at end of file +2b15950995d163e68e50e2aabf1b4e9a4ff2dfeb \ No newline at end of file diff --git a/ippisite/ippidb/management/commands/import_v1_data.py b/ippisite/ippidb/management/commands/import_v1_data.py index 1f6c40e71256bdfc612b1a291f2c09e89493b6f8..622ede9604849163d251b3b58e0346c84489a549 100644 --- a/ippisite/ippidb/management/commands/import_v1_data.py +++ b/ippisite/ippidb/management/commands/import_v1_data.py @@ -9,6 +9,18 @@ from ippidb.models import Bibliography, Protein, Taxonomy, MolecularFunction, \ Domain, ProteinDomainBoundComplex, ProteinDomainPartnerComplex, Symmetry, Ppi, PpiComplex, Disease, \ Compound, MDDRCompoundImport, MDDRActivityClass +class MyConverter(mysql.connector.conversion.MySQLConverter): + + def row_to_python(self, row, fields): + row = super(MyConverter, self).row_to_python(row, fields) + + def to_unicode(col): + if type(col) == bytearray: + return col.decode('utf-8') + return col + + return[to_unicode(col) for col in row] + class Command(BaseCommand): help = "Import data from the local v1 database" @@ -73,7 +85,7 @@ class Command(BaseCommand): def handle(self, *args, **options): - conn = mysql.connector.connect(host="localhost",user="root",password="ippidb", database="ippidb") + conn = mysql.connector.connect(converter_class=MyConverter, host="localhost", user="root", password="ippidb", database="ippidb") cursor = conn.cursor() if options['bibliographies']: cursor.execute("""SELECT * FROM biblio""")