[Pipet Devel] Gadfly info
Brad Chapman
chapmanb at arches.uga.edu
Wed Feb 9 10:20:27 EST 2000
Okee dokee, here's the little bit I know about getting Gadfly running.
1. Go get Gadfly from: http://www.chordate.com/gadfly.html
2. Follow the install instructions to get it running.
(http://www.chordate.com/kwParsing/gadfly.html). It's written in all
python, so just unpack it in your classpath and run one python command.
3. Either use the test script provided with Gadfly or my little test
script (with comments) at the bottom of this page, to create a
database. The trick is that you have to create a directory to store
the database info in. I have been using '/usr/local/gadfly/data' to
store my stuff. If you want to use this, you have to create this
directory. If you want to use something else, you have to change the
gadflyDir variable in my test script below, and also go to
loci/main/library/modules/const.py and edit the gadflyDirectory
variable there (there is a note about this in the INSTALL file).
4. Okay, now you have a database created and are ready to look at in
loci so start up loci in the usual manner.
5. Create a container loci. Click on the DB button, and you'll be
presented with a dialog to enter info about the database to connect to.
6. For gadfly, it is really easy--just type in gadfly in the database
type box, and click OK.
7. The container widget should now have a loci inside of it with your
test database. To look at its contents, click on it, and then drag it
onto the workspace.
8. Now open up the new container, and you'll see the tables in the
database. Click on the created table, and drag it onto the workspace.
9. Now you should have a document loci representing that table. Double
click on it, and you should see a widget displaying the columns and
the info in each column. Of course, now you can also see a current bug
(sorry!). Gadfly doesn't return the column info in the manner in which
its inserted in the database--I just started using Gadfly, and I'll
need to play around with it more to fix this.
10. Ta Da, that's it!
Please let me know if you have any problems/comments. My next thing to
work on will be inserting information into databases, so hopefully
very soon we shouldn' t have to worry about test scripts/etc--it will
all be able to be done from Loci. Yay!
Brad
Test Script
-----------
# Note: you'll probably need to fix up the indents on this.
#!/usr/bin/env python
import sys
def main(argv):
"""
A little python script to create a gadfly database.
"""
# The directory where gadfly DBs should be stored.
# This directory *must* already exist, and be writable and all that.
gadflyDir = '/usr/local/gadfly/data'
# connect to gadfly
import gadfly
connection = gadfly.gadfly()
# make the database
connection.startup("LociTestDB", gadflyDir)
# create a cursor to do things with the database
cursor = connection.cursor()
# create a table
tableSQL = "CREATE TABLE ILikeLoci(col1 varchar, col2 varchar, col3
varchar, col4 integer)"
cursor.execute(tableSQL)
# insert something in the table
insertSQL = "INSERT INTO ILikeLoci(col1, col2, col3, col4) values
('Loci', 'is', 'number', 1)"
cursor.execute(insertSQL)
insertSQL2 = "INSERT INTO ILikeLoci(col1, col2, col3, col4) values
('My', 'Biochem', 'Grade', 23)"
cursor.execute(insertSQL2)
# commit the changes and close the connection
connection.commit()
connection.close()
print 'Now you've got a Gadfly database! Try to contain your
excitement.'
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
More information about the Pipet-Devel
mailing list