raindrop database python console

1 view
Skip to first unread message

Bryan Clark

unread,
Aug 11, 2010, 7:01:30 PM8/11/10
to raindr...@googlegroups.com
Hey -

I'll admit that I've used rails (Ruby on Rails) a number of times so
I've taken their data access console idea and implemented for Raindrop.

My latest commit [1] is a Raindrop Database interactive console. It
uses the Python Interactive console but loads up the Raindrop data
environment so you can play with the data objects via the command line.

Here's some examples of how it works: (> is the terminal >>> is the
python console)

> ./raindrop/scripts/raindrop-console.py
>>> Session.query(Message).all()
[<Message(id=5)>,<Message(id=6)>,<Message(id=10)>, ... ]
>>> Session.query(Message).all()[3]
<Message(id=9)>
>>> Session.query(Message).all()[3].recipients
[<raindrop.model.coreobjects.MessageRecipient object at 0x1a4e8f0>]
>>> Session.query(Message).all()[3].recipients[0].recip_type
0

You can use the dir() function when you're browsing the items if you
want a quick check of what methods are available.

>>> dir(Session.query(Message).all()[3].recipients)
[ ... '_sa_remover', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']


Or you could open up the python docs related to a specific object so you
get a much better look at the specific attributes on an object being
returned.

>>> help(Session.query(Message).all()[3].recipients[0])
<opens help docs for type; q to quit>


The goal is just to help out when you're working with the database
objects in the code and you want to know what are the available methods
or objects. This also allows me to edit or update objects in the
system. e.g. Mark all my messages unread or read if I have UI that's
playing with those attributes.

Let me know if there are any issues,
~ Bryan

[1]
http://hg.mozilla.org/users/mhammond_skippinet.com.au/raindrop-reboot/rev/ed7cfe7bcbb5

Shane Caraveo

unread,
Aug 11, 2010, 8:00:01 PM8/11/10
to raindr...@googlegroups.com, Bryan Clark
On 10-08-11 4:01 PM, Bryan Clark wrote:
>
>
> I'll admit that I've used rails (Ruby on Rails) a number of times so
> I've taken their data access console idea and implemented for Raindrop.
>
> My latest commit [1] is a Raindrop Database interactive console. It
> uses the Python Interactive console but loads up the Raindrop data
> environment so you can play with the data objects via the command line.

Have you looked at the paste shell? It's part of pylons, and only works
in the root dir of a pylons project, but may offer some capabilities
that could be interesting.

cd storm
paster shell


shane


Reply all
Reply to author
Forward
0 new messages