[Biopython-dev] BioSQL bugs

Marc Colosimo mcolosimo at mitre.org
Wed Mar 24 15:28:29 EST 2004


First,  I've added support for pgdb to DBUtils and did some testing the 
diff is at the end. Second the fix for taxon doesn't work. The problem 
is that it tries to enter NULLs for fields that are required to be 
unique.

BioSQL.Loader
line 188 parent_taxon_id = None
	for taxon in lineage:
             self.adaptor.execute(
                 "INSERT INTO taxon(parent_taxon_id, ncbi_taxon_id, 
node_rank,"\
                 " left_value, right_value)" \
                 " VALUES (%s, %s, %s, %s, %s)", (parent_taxon_id,
                                                  taxon[0],
                                                  taxon[1],
                                                  left_value,
                                                  right_value))

This might work the first time, but since parent_taxon and other need 
to be unique this fails. I don't know a simple solution for this, 
except to give up and not put in a taxon_id (which isn't required for a 
bioentry).

Index: DBUtils.py
===================================================================
RCS file: /home/repository/biopython/biopython/BioSQL/DBUtils.py,v
retrieving revision 1.2
diff -r1.2 DBUtils.py
37c37
< class Pg_dbutils(Generic_dbutils):
---
 > class Psycopg_dbutils(Generic_dbutils):
54c54,75
< _dbutils["psycopg"] = Pg_dbutils
---
 > _dbutils["psycopg"] = Psycopg_dbutils
 >
 > class Pgdb_dbutils(Generic_dbutils):
 >     def next_id(self, cursor, table):
 >         table = self.tname(table)
 >         sql = r"select nextval('%s_pk_seq')" % table
 >         cursor.execute(sql)
 >         rv = cursor.fetchone()
 >         return rv[0]
 >
 >     def last_id(self, cursor, table):
 >         table = self.tname(table)
 >         sql = r"select currval('%s_pk_seq')" % table
 >         cursor.execute(sql)
 >         rv = cursor.fetchone()
 >         return rv[0]
 >
 >     def autocommit(self, conn, y = True):
 >         raise NotImplementedError("pgdb does not support this!")
 >
 > _dbutils["pgdb"] = Pgdb_dbutils
 >





More information about the Biopython-dev mailing list