[BioPython] Bug in BioSQL/Loader.py

Eric Gibert ericgibert at yahoo.fr
Thu Nov 8 14:21:31 UTC 2007


Dear all,

Bug 1)  I noticed that the SQL statement "INSERT INTO bioentry...." in line 229 is missing one %s.

I added it and it works fine... until the bug on the next command:
    bioentry_id = self.adaptor.last_id('bioentry')  

which causes the old timer bug 2  in DBUtils.py line 34: MySQL is now using lastrowid and no longer insert_id()

Correction as per below:
---------------------------------------------
class Mysql_dbutils(Generic_dbutils):
    def last_id(self, cursor, table):
        return cursor.lastrowid        # <-- EG original command: cursor.insert_id()
_dbutils["MySQLdb"] = Mysql_dbutils
-----------------------------------------------

Then this leads me to the follow bug 3 --- or maybe this is *not* a bug ?  --- I explain:

In my BioSQL database, the table  'seqfeature_qualifier_value' as the following schema:

seqfeature_id        int(11)
term_id                 int(11)
value                     varchar(255)
rank                       int(11)

note that first we have 'value' then we have 'rank'.

But the  'INSERT INTO seqfeature_qualifier_value' statement found in  BioSQL/Loader.py line 453 is:


                    qualifier_value = qualifiers[qualifier_key][qual_value_rank]
                    sql = r"INSERT INTO seqfeature_qualifier_value VALUES" \
                          r" (%s, %s, %s, %s)"
                    self.adaptor.execute(sql, (seqfeature_id,
                                               qualifier_key_id,
                                               qual_value_rank + 1,
                                               qualifier_value))


thus I need to invert the last two elements of the list. As I said, I do not know if my BioSQL schema is correct or not.
If my schema is correct then my correction is obvious:
                     self.adaptor.execute(sql, (seqfeature_id,
                                               qualifier_key_id,
                                               qualifier_value,        # EG invert the two last params
                                               qual_value_rank + 1
                                               ))


------------------
Finally, the script executes without error and .... nothing happens! It looks like there is no 'commit' nowhere and so the new records are not inserted in the database.

Although the psychopg database enjoys a:

    def autocommit(self, conn, y = True):
        conn.autocommit(y)
_dbutils["psycopg"] = Psycopg_dbutils

MySQL does not have such an overload for 'autocommit' in DBUtils.py. Could this fix the problem ?

In the file MySQLdb/connections.py, on line 213, we have:
            # PEP-249 requires autocommit to be initially off
            self.autocommit(False)

Therefore the source for the Mysql_dbutils class is now:

class Mysql_dbutils(Generic_dbutils):
    def last_id(self, cursor, table):
        return cursor.lastrowid        #EG original command: cursor.insert_id()

    def autocommit(self, conn, y = True): # EG addition as by default it is set to False
        conn.autocommit(y)

_dbutils["MySQLdb"] = Mysql_dbutils


Unfortunately, this is *NOT* fixing the lack of 'commit'. I need your help...

Cordialement,

Eric









      ____________________________________________________________________________________________
Découvrez le blog Yahoo! Mail : le nouveau Yahoo! Mail, astuces, conseils.. et vos réactions !
http://blog.mail.yahoo.fr



More information about the Biopython mailing list