Mercurial > repos > kellrott > nosql_interface
view mongo_client.xml @ 2:1fce03693725 draft
Uploaded
author | kellrott |
---|---|
date | Tue, 24 Jul 2012 17:41:32 -0400 |
parents | bda961c955d5 |
children |
line wrap: on
line source
<tool id="mongo_client" name="Mongo Client" version="1.0.0"> <description>Mongo Client</description> <command interpreter="python">$scriptfile</command> <inputs> <param name="server" type="text" size="52" label="Server address"/> <param name="port" type="integer" label="Server Port" value="27017"/> <param name="db" type="text" size="32" label="Database"/> <param name="collection" type="text" size="32" label="Collection"/> <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 pymongo import json import galaxy.eggs import galaxy.util query=galaxy.util.restore_text("""$query""") conn = pymongo.Connection(galaxy.util.restore_text("$server"), $port) db = conn[galaxy.util.restore_text('$db')] collection = db[galaxy.util.restore_text('$collection')] qObj = None if len(query): qObj = json.loads(query) handle = open(galaxy.util.restore_text("$output"), "w") for row in collection.find(qObj): handle.write("%s\n" % (json.dumps(row))) handle.close() ]]></configfile> </configfiles> <help> Info about the Mongo Query Syntax: - `Mongo Query Language <http://www.mongodb.org/display/DOCS/Mongo+Query+Language>`_ - `Advanced Queries <http://www.mongodb.org/display/DOCS/Advanced+Queries>`_ </help> </tool>