Annie12345
Programmer
Hi, I have a script to search for strings in a file and look them up in a database, however sql won't accept my string (for example ENSG00000152822), how should I do it?
import MySQLdb
db = MySQLdb.connect(host = "ensembldb.sanger.ac.uk",user = "anonymous", passwd = "", db = "ensembl_mart_23_1")
cursor = db.cursor()
for line in open('list.txt').readlines():
array = line.split("\t")
ensemblid = array[1]
cursor.execute("select gene_stable_id, display_id from hsapiens_gene_est__gene__main where gene_stable_id= ???ensemblid??? ")
print cursor.fetchall()
Thanks for you help
import MySQLdb
db = MySQLdb.connect(host = "ensembldb.sanger.ac.uk",user = "anonymous", passwd = "", db = "ensembl_mart_23_1")
cursor = db.cursor()
for line in open('list.txt').readlines():
array = line.split("\t")
ensemblid = array[1]
cursor.execute("select gene_stable_id, display_id from hsapiens_gene_est__gene__main where gene_stable_id= ???ensemblid??? ")
print cursor.fetchall()
Thanks for you help