Skip to content

Instantly share code, notes, and snippets.

@chromakode
Created March 24, 2010 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chromakode/342577 to your computer and use it in GitHub Desktop.
Save chromakode/342577 to your computer and use it in GitHub Desktop.
mgood@capstone11 ~/D/c/b/boots.mgood> boots -H capstonedd -l python
Boots (v0.2.0)
capstonedd:3306 (server v2009.11.1220)
> from boots.api import constructors
> @constructors.register('reverse')
+ def reverse():
+ from boots.api.nodes.node import SyncNode
+ from boots.api.api import Rows
+ def reverse_data(data):
+ return Rows((("".join(reversed(field)) if isinstance(field,basestring) else field
+ for field in row)
+ for row in data)
+ , data.description)
+
+ return SyncNode(reverse_data)
+
> \use pipedsql
> use world;
0 rows affected (0.00 seconds)
> SELECT * FROM city WHERE district='Oregon'; | reverse()
+------+----------+-------------+----------+------------+
| ID | Name | CountryCode | District | Population |
+------+----------+-------------+----------+------------+
| 0283 | dnaltroP | ASU | nogerO | 121925 |
| 0593 | eneguE | ASU | nogerO | 398731 |
| 2593 | melaS | ASU | nogerO | 429631 |
+------+----------+-------------+----------+------------+
3 rows in set (0.00 seconds)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment