Mercurial > repos > kellrott > nosql_interface
changeset 0:907b95ba9cf7 draft
Uploaded
author | kellrott |
---|---|
date | Tue, 24 Jul 2012 17:40:26 -0400 |
parents | |
children | bda961c955d5 |
files | couchdb_client.xml |
diffstat | 1 files changed, 46 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/couchdb_client.xml Tue Jul 24 17:40:26 2012 -0400 @@ -0,0 +1,46 @@ +<tool id="couchdb_client" name="CouchDB Client" version="1.0.0"> + <description>CouchDB Client</description> + <command interpreter="python">$scriptfile</command> + <inputs> + <param name="url" type="text" size="128" label="Server URL"/> + <param name="db" type="text" size="32" label="Database"/> + <param name="query" type="text" area="True" size="5x25" label="Query"> + <sanitizer> + <valid initial="string.printable"/> + <mapping initial="none"> + <add source=" " target="__cn__"/> + <add source=""" target="__dq__"/> + </mapping> + </sanitizer> + </param> + </inputs> + <outputs> + <data name="output" format="txt"/> + </outputs> + <configfiles> + + <configfile name="scriptfile"><![CDATA[#!/usr/bin/env python +import couchdb.client +import json +import galaxy.eggs +import galaxy.util + +server = couchdb.client.Server(galaxy.util.restore_text("$url")) +db = server['$db'] + +query=galaxy.util.restore_text("""$query""") +print query +result = db.query(query) +print result +handle = open(galaxy.util.restore_text("$output"), "w") +for row in result: + handle.write("{\"key\":%s, \"value\":%s}\n" % (json.dumps(row.key), json.dumps(row.value))) +handle.close() + +]]></configfile> + </configfiles> +<help> + + +</help> +</tool>