Biopython bioSQL Unable to remove database using server.remove_database('dbname')

43 views Asked by At

bioSQL Unable to remove database using

server.remove_database('dbname')

Just installed the biosql and with mysql and tried to create test database with name "orchids". It created and add some data to subdatabse via Entrez. But problem is when trying to delete whole subdatabase with using server.remove_database("orchids") it gives error. All codes were got from https://biopython.org/wiki/BioSQL

from BioSQL import BioSeqDatabase
from Bio import Entrez
from Bio import SeqIO


server = BioSeqDatabase.open_database(
    driver="mysql.connector",
    user="biosqlUser",
    passwd="password",
    host="localhost",
    db="biosql",
)

db = server["orchids"]

server.remove_database("orchids") 
server.commit()

Traceback (most recent call last):

File "/home/new/test.py", line 23, in <module>
    server.remove_database("orchids") 
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'DBServer' object has no attribute 'remove_database'. Did you mean: 'new_database'?
1

There are 1 answers

0
Umar On BEST ANSWER

The error you are encountering is due to the use of an incorrect method. The DBServer object does not have a remove_database method. Instead, you should use the remove_database method of the BioSeqDatabase object. Here's the corrected code:

from BioSQL import BioSeqDatabase
from Bio import Entrez
from Bio import SeqIO

server = BioSeqDatabase.open_database(
    driver="mysql.connector",
    user="biosqlUser",
    passwd="password",
    host="localhost",
    db="biosql",
)

db = server["orchids"]
server.remove_database(db)  # Use the remove_database method of the BioSeqDatabase object
server.commit()