[BioPython] mysql trouble

Rafael C. Jimenez rafael at nbn.ac.za
Wed Apr 6 02:27:55 EDT 2005


Try to create a cursor of  "conn" and then use the method execute to 
process the query.

See one example from the MySQLdb help:

#!/usr/bin/python
# import MySQL module
import MySQLdb
# connect
db = MySQLdb.connect(host="localhost", user="joe",
passwd="secret",
db="db56a")
# create a cursor
cursor = db.cursor()
# execute SQL statement
cursor.execute("""INSERT INTO animals (name, species) VALUES
("Harry",
"Hamster")""")

Good luck with your project!
Cheers,
Rafael.

On 31/03/2005, at 12:30, pap501 at york.ac.uk wrote:

> Hi
>
> I am a masters student at the University of York working on a project 
> to create a database of DNA sequences.
>
> I am trying to grab information from text files using a python script 
> to insert data into a MySQL table. The problem is that although I can 
> query MySQL through Python I cannot write into MySQL through Python. I 
> am using the Windows platform with Python version 2.4 with Biopython 
> installed and MySQL Server 4.1.
>
> I have attached my python script to this email.
> The script takes each text file in turn (although only one is listed 
> in the script at the mo) and inserts the library code, Genbank code 
> (primary key), TiGR code (if there is one, null otherwise) and the DNA 
> sequence (string of characters). Each file is a library of ~2000 DNA 
> sequences. The python script runs but does not write the information 
> into my MySQL table. When I query the table in MySQL it says that the 
> table is empty.
>
> Can anyone advise me what to do? Is it soemthing to do with the setup 
> of MySQL and/or Python or a problem with the Python script?
>
> Any advice would be greatly appreciated.
>
> Many thanks
>
> Phil<library.py>_______________________________________________
> BioPython mailing list  -  BioPython at biopython.org
> http://biopython.org/mailman/listinfo/biopython



More information about the BioPython mailing list