[BioPython] Problem with python and mysql
Larry
l.heisler at utoronto.ca
Thu Mar 31 11:00:00 EST 2005
Hi Phil,
I don't believe .query can be used with a MySQLdb connection. I am not an
expert on this, but the way I have done this in the past is
1. set up the connection
conn= MySQLdb.connect (host="localhost",
user ="root",
passwd ="p1geon1",
db="phil")
2. set up a cursor
mycursor=conn.cursor()
3. create your query
qry="insert into sequences2 values('%s','%s','%s','%s');"% (a, gb, tnum,
seq)
4. execute your query
mycursor.execute(qry)
others may be able to give you more details on this, ie. using .query which
i believe works with _mysql
ie
use _mysql
conn= _mysql.connect (host="localhost", user ="root", passwd
="p1geon1",db="phil")
conn.query(qry)
Larry
----- Original Message -----
From: <pap501 at york.ac.uk>
To: <biopython at biopython.org>
Sent: Thursday, March 31, 2005 5:21 AM
Subject: [BioPython] Problem with python and mysql
> 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
----------------------------------------------------------------------------
----
> _______________________________________________
> BioPython mailing list - BioPython at biopython.org
> http://biopython.org/mailman/listinfo/biopython
>
More information about the BioPython
mailing list