A simple example of using a Python MySQL library to access the OpenWorm Semantic Database.

In [1]:
!sudo pip install PyMySQL
Downloading/unpacking PyMySQL
  Downloading PyMySQL-0.5.tar.gz
  Running setup.py egg_info for package PyMySQL
    
Installing collected packages: PyMySQL
  Running setup.py install for PyMySQL
    
Successfully installed PyMySQL
Cleaning up...
In [7]:
#!/usr/bin/env python

import pymysql

#conn = pymysql.connect(host='127.0.0.1', unix_socket='/tmp/mysql.sock', user='root', passwd=None, db='mysql')

conn = pymysql.connect(host='my01.winhost.com', port=3306, user='openworm', passwd='openworm', db='mysql_31129_celegans')
   
cur = conn.cursor()

cur.execute("SELECT DISTINCT EnID1 FROM tblrelationship LIMIT 5")

# print cur.description

# r = cur.fetchall()
# print r
# ...or...
for r in cur.fetchall():
   print(r)

cur.close()
conn.close()
(39L,)
(48L,)
(49L,)
(40L,)
(41L,)
In [ ]: