def savedb(self,Db=None,annotation='refGene',overwrite=False):
        """write a database file and create a table in it.
        
        If a database file already exists, just create a table"""
        
        # connect to the local database
        dbconnect=sqlite3.connect(Db)
        cursor=dbconnect.cursor()

        # create a db table
        other_columns=[column for column in self.columns if column!='chrom']
        columns=['chrom']
        columns.extend(other_columns)
        sqlcmd="""create table %s (""" %(annotation)+','.join(columns)+""")"""
        try:
            cursor.execute(sqlcmd)
        except sqlite3.OperationalError,e:
            if overwrite:
                warnings.warn("Overwritting the existing table with the current one")
                cursor.execute("""drop table %s""" %(annotation))
                cursor.execute(sqlcmd)
            else:
                raise sqlite3.OperationalError(e)
        
        # write the table into the db table
        num_columns=len(columns)
        chroms=self.table.keys()
        chroms.sort()
        for chrom in chroms:
            for i in xrange(0,len(self.table[chrom][other_columns[0]])):
                sqlcmd=(annotation) %"""insert into %s values ("""+', '.join(['?' for ix in range(0,num_columns)])+""")""" 
                export_data=[chrom]    
                for column in other_columns:
                    element=self.table[chrom][column][i]
                    if type(element).__name__=='array': element=str(element.tolist())[1:-1]+','
                    export_data.append(element)
                export_data=tuple(export_data)
                cursor.execute(sqlcmd,export_data)
                
        # save the change
        dbconnect.commit()
        #close the database file
        cursor.close()
        dbconnect.close()
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/GeneTable.savedb/swapped operands of `%`